GUI Tutorial

From Dyrdex.com
Revision as of 21:19, 24 April 2022 by Admin (talk | contribs) (Created page with "People keep asking how to set up the gui, so, here's some information you can expand upon. The GUI is set up using the #SPLIT and #DRAW commands, and using your #VAR's. Fir...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

People keep asking how to set up the gui, so, here's some information you can expand upon.

The GUI is set up using the #SPLIT and #DRAW commands, and using your #VAR's.

First, establish your desired top/bottom screen #SPLIT:

#ALIAS {split} {
 #SPLIT 5 5;
 #BUFFER end;
 }


Second, you can draw tiles of all the vars you want to populate your split region however you want. Here I'm formatting an existing var, then drawing its tile:

#ALIAS {draw} {
 #FORMAT {room_string} {%c%.44s} {<ddd>}{$msdp_info[ROOM_NAME]};
 #DRAW tile 3 2 3 44 $room_string;
 }

Just add every var you want to draw to screen into that draw alias really. You'll have to read #Help draw to understand all your options, and how to use the coordinate system to place those into exact positions on screen. You'll also want to learn #FORMAT so you can align those and specify their lengths to avoid overrun.


Instead of drawing individual tiles, you can also generate a list and draw that all at once.

Here, we will generate such a list, and then also create a sidebar box, and draw the whole list in there:

First, format your vars into a list:

#alias get_affects {
        #list affects clear;
        #foreach {*msdp_info[AFFECTS][]} {affect}
        {
                #if {$msdp_info[AFFECTS][$affect] < 50} {#var Color {<dbb>}};
                #if {$msdp_info[AFFECTS][$affect] > 49 && $msdp_info[AFFECTS][$affect] < 99} {#var Color {<ffd>}};
                #if {$msdp_info[AFFECTS][$affect] > 99} {#var Color {<ddd>}};
                #format {affect_line} {%c%+15.15s %c%-4s%c} {<bbb>}{$affect}{$Color}{$msdp_info[AFFECTS][$affect]}{<ddd>};
                #LIST {affects} {add} {$affect_line};
        };
        #unvar Color;
        #unvar affect_line;
};

That will generate a $affects var. Do #VAR affects to look at that.

So now let's do a sidebar, and draw a whole $affects list there.

First, use the #SCREEN command to get information about your existing #SPLIT, so you can re-split to have a sidebar (29 spaces in this example). We also need to do #BUFFER end to reprint the scrolling region, and our original 'draw' alias to draw the normal top/bottom split data into place. Finally we will set a #var sidebar 1 just to track that the sidebar is indeed turned off, so we can use that info later.

  1. ALIAS {side_split} {
       #SCREEN get split_top_bar screen[split_top];
       #SCREEN get split_bot_bar screen[split_bot];
       #SCREEN get split_left_bar screen[split_left];
       #SCREEN get split_right_bar screen[split_right];
       #SPLIT  $screen[split_top] $screen[split_bot] 0 29;
       #BUFFER end;
       draw;
       #VAR sidebar 1;
       }

Second, draw a box with your list data into the new side split region. I'm drawing the box 'blue' here so you can see it, can change that to 'blanked' to make the outline invisible if you desire:

#alias draw_sidebar {
       #MATH {mod_top} {$screen[split_top] + 1};
       #MATH {mod_bottom} {$screen[split_bot] + 2};
       #draw blue box $mod_top -24 -$mod_bottom -1 $affects[1..-1];
       };

};


Then, make a single alias that does the entire side operation:

#ALIAS {sidebar} {get_affects;side_split;draw_sidebar}

Finally, make an alias to toggle the sidebar on/off by checking the $sidebar var.

#ALIAS {affs} {
     #IF {"$sidebar" == "1"} {#VAR sidebar 0;#SPLIT 5 5;#BUFFER end;draw};   (This eliminates the sidebar split, and does your basic split & gui draw)
     #ELSE {get_affects;side_split;draw_sidebar};                            (This gens the var, adds the sidebar, draws it)
     }

So, typing 'affs' will turn the side bar on if it was off, and then turn it off again if it was on. It's a toggle.


Now, let's say you want that to auto-update that sidebar every time your affects vars update.

Inside your MSDP script code, at the point where it is parsing the AFFECTS string, you can put this check:

#IF {"$sidebar" == "1"} {draw_sidebar};