Results 1 to 5 of 5

Thread: [CC3-TIP] Building Hotspots in a macro

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Guild Apprentice
    Join Date
    Jun 2006
    Location
    Hamilton, Ontario, CANADA
    Posts
    47

    Post [CC3-TIP] Building Hotspots in a macro

    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.

    Code:
    MACRO ML_DRAWBTN
    sheet MAP BORDER
    setlayer BUTTONS
    color 15
    fstyle Hollow
    box pButtonL pButtonH
    The box drawn above will be the button's visible frame.
    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 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:
    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
    The 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 MAP BORDER
    GoCurLvl
    color 4
    fstyle Solid
    box pButtonL pButtonH
    ENDM
    The above code draws a yellow box that "backlights" the button of the currently active level.

    --

    Dalton "who hopes that this idea stays clever" Spence

  2. #2
    Administrator Facebook Connected Robbie's Avatar
    Join Date
    Mar 2006
    Location
    Dayton, OH
    Posts
    3,877
    Blog Entries
    6

    Post

    Oh now that is just cool...Can't wait to check it out when I get home.
    Fantaseum (https://www.fantaseum.com)

    Robbie Powell - Site Admin

  3. #3
    Community Leader RPMiller's Avatar
    Join Date
    Apr 2006
    Location
    Watching you from in here
    Posts
    3,226

    Post

    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.

  4. #4
    Guild Apprentice
    Join Date
    Jun 2006
    Location
    Hamilton, Ontario, CANADA
    Posts
    47

    Post

    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.
    Code:
    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
    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 is
    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

  5. #5
    Administrator Facebook Connected Robbie's Avatar
    Join Date
    Mar 2006
    Location
    Dayton, OH
    Posts
    3,877
    Blog Entries
    6

    Post

    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?
    Fantaseum (https://www.fantaseum.com)

    Robbie Powell - Site Admin

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •