Oh now that is just cool...Can't wait to check it out when I get home.
The macro below draws a hotspot button at a specified location. I use it to create a control panel for multilevel floorplans that use layers for levels. The following variables must be set before running it:
- "pButtonL" and "pButtonH": point variables containing lower left and upper right corners of the hotspot button,
- "nCurLvl": a numeric variable containing the current structure level number.
The box drawn above will be the button's visible frame.Code:MACRO ML_DRAWBTN sheet MAP BORDER setlayer BUTTONS color 15 fstyle Hollow box pButtonL pButtonH"GoCurLvl" is a macro that converts the level number into a layer name which it then makes current. Note how I split the variable and macro names while building the macro command string (sMacCmd) so they don't expand and terminate the string with a delimiter.Code:gl sMacCmd ~gn nCur apnd sMacCmd Lvl apnd sMacCmd; apnd sMacCmd nCurLvl apnd sMacCmd; apnd sMacCmd GoCur apnd sMacCmd Lvl apnd sMacCmd; color 2 tspech 1 actionm sMacCmd pButtonL pButtonHThe above code finds the center of the hotspot and places the level number there as a text label. On my maps the TEXT sheet is above the MAP BORDER one. Note how the text height is half the button height.Code:sheet TEXT color 15 getx vX1 pButtonL gety vY1 pButtonL getx vX2 pButtonH gety vY2 pButtonH gp pButtonC (vX1+vX2)/2,(vY1+vY2)/2 tspech (vY2-vY1)/2 textm nCurLvl pButtonCThe above code draws a yellow box that "backlights" the button of the currently active level.Code:sheet MAP BORDER GoCurLvl color 4 fstyle Solid box pButtonL pButtonH ENDM
--
Dalton "who hopes that this idea stays clever" Spence
Oh now that is just cool...Can't wait to check it out when I get home.
Very nice indeed Dalton! I'm assuming that the dimensions are set with button clicks? I'm not on my CC machine, but will be testing it over the holiday for sure. Thanks for sharing it.
At the moment it's used by a parent macro that calculates the button corners for each structure level to produce an elevator style button panel, but a shell macro that draws a single button is easily written.Note that most of this macro is about making sure that pButtonL is the lower left corner and pButtonH is the upper right. I also made a slight change in the ML_DRAWBTN macro code by placing the last section (that draws the yellow "backlit" box) first so the out-of-range error check in the GoCurLvl macro is run before anything is drawn. The revised code isCode:MACRO ML_OneBtn gp pButtonL ^DSelect lower left corner of button: gp pButtonH ^DSelect upper right corner of button: getx vX1 pButtonL getx vX2 pButtonH gety vY1 pButtonL gety vY2 pButtonH ifn vX1-vX2 ML1B_FlipX getx vX2 pButtonL getx vX1 pButtonH :ML1B_FlipX ifn vY1-vY2 ML1B_FlipY getY vY2 pButtonL getY vY1 pButtonH :ML1B_FlipY gp pButtonL vX1,vY1 gp pButtonH vX2,vY2 gn nCurLvl ^DEnter level # button goes to: ML_DRAWBTN ENDM--Code:MACRO ML_DRAWBTN GoCurLvl sheet MAP BORDER color 4 fstyle Solid box pButtonL pButtonH setlayer BUTTONS color 15 fstyle Hollow box pButtonL pButtonH gl sMacCmd ~gn nCur apnd sMacCmd Lvl apnd sMacCmd; apnd sMacCmd nCurLvl apnd sMacCmd; apnd sMacCmd GoCur apnd sMacCmd Lvl apnd sMacCmd; color 2 tspech 1 actionm sMacCmd pButtonL pButtonH sheet TEXT color 15 getx vX1 pButtonL gety vY1 pButtonL getx vX2 pButtonH gety vY2 pButtonH gp pButtonC (vX1+vX2)/2,(vY1+vY2)/2 tspech (vY2-vY1)/2 textm nCurLvl pButtonC ENDM
Dalton "who loves feedback; it makes me smarter " Spence
Dalton yer awesome. since you seem to be a hella-scripter do you think you could answer the fillstyle question in my stair shading macro thread?