Author Topic: Creating a user interface, step by step  (Read 21072 times)

0 Members and 1 Guest are viewing this topic.

Offline TrailMyxTopic starter

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13301
  • Activity:
    0%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Creating a user interface, step by step
« on: June 18, 2008, 12:25:52 PM »
+1
There seems to be a lot of confusion about how user interfaces work in EasyUO.  Actually there are many ways to implement these, so in this example I will describe creating a UI that will:

1) Continuously scan for user input
2) Continuously update the user interface for changing information.

The initial structure:

Script flow is important when setting up a user interface.  You don't want to call a menu item constructor more than once, so typically you will have one routine that will draw your entire user interface panel.  After the initial drawing, you may delete/add menu items as the script runs.  The code generated by the EasyUO Menu Designer lends itself perfectly to this method since all the necessary code to draw your newly created UI is located in one sub typicall named showEUOMenu1.

So here is the basic layout of a user interfaced script:

1) Setup your UI panel (typically a call to showEUOMenu1 or your own UI code)
2) Setup of your variables used for your script.
3) Main loop starts here
4)     Update UI information (handling input read (menu get) from UI controls via #MENURES
5)     Sample UI input from #MENUBUTTON
6)     If #MENUBUTTON <> N/A, then handle this button action (possibly 1+ function per button action)
7)     Housekeeping routines
8 )     Loop back to Main loop

Here is an example script which I wrote specifically for this tutorial:



Code: easyuo
  1. ;=================================================================
  2. ; Script Name: TrailMyx's UI Tutorial - Spellcasting
  3. ; Author: TrailMyx
  4. ; Version: 0.68
  5. ; Shard OSI / FS: OSI / FS OK
  6. ; Revision Date: 9/29/2007
  7. ;
  8. ; Purpose:
  9. ;
  10. ; Globals/System variables:
  11. ;
  12. ; Special Thanks:
  13. ;
  14. ; Revision History:
  15. ;
  16. gosub showEUOMenu1
  17. gosub Setup
  18. set #MENUBUTTON N/A
  19.  
  20. set %current_circle 1
  21. set %current_log_selection 0
  22. set %last_target N/A
  23.  
  24. mainloop1:
  25. ;
  26. ; Update Window
  27. ;
  28.   gosub UpdateLogWindow
  29.  
  30.   menu get CircleMenu
  31.   if #MENURES <> %current_circle
  32.   {
  33.     set %current_circle #MENURES
  34.     gosub UpdateSpellMenu %current_circle
  35.   }
  36.  
  37.   menu get EUOListLogWindow
  38.   if #MENURES <> %current_log_selection
  39.   {
  40.     set %current_log_selection #MENURES
  41.     set %temp %journal . %current_log_selection
  42.     menu set EUOStatus %temp
  43.   }
  44. ;
  45. ; Handle Buttons/Checkmarks
  46. ;
  47.   if #MENUBUTTON = EUOButtonCast
  48.   {
  49.     set #MENUBUTTON N/A ; Always remember to reset #MENUBUTTON when you handle it!
  50.     menu delete EUOShape1
  51.     menu Shape EUOShape1 168 40 105 21 3 7 1 Black 7 Red
  52.     menu get CircleMenu
  53.     set %circle #MENURES
  54.     menu get SpellMenu
  55.     set %spell #MENURES
  56.     menu get EUOCheckWaitForTarget
  57.     set %waitfortarget #MENURES
  58.  
  59.     if %circle = 9 ; Computer the event macro 15 spell number...
  60.       set %spell_num 100 + %spell
  61.     else
  62.       set %spell_num ( ( %circle - 1 ) * 8 ) + %spell - 1
  63.  
  64.     event macro 15 %spell_num
  65.     if %waitfortarget = #TRUE
  66.     {
  67.       target 10s
  68.       if %last_target = N/A
  69.       {
  70.         repeat
  71.         until #TARGCURS = 0
  72.         set %last_target #LTARGETID
  73.       }
  74.       event macro 22 0
  75.     }
  76.     menu get EUOEditDelay
  77.     wait #MENURES
  78.     menu delete EUOShape1
  79.     menu Shape EUOShape1 168 40 105 21 3 7 1 Black 7 Lime
  80.   }
  81.  
  82.   if #MENUBUTTON = EUOButtonResetTarget
  83.   {
  84.     set #MENUBUTTON N/A ; Always remember to reset #MENUBUTTON when you handle it!
  85.     set %last_target N/A
  86.   }
  87.  
  88.   menu get EUOCheckLoop
  89.   if #MENURES = #TRUE
  90.   {
  91.     set #MENUBUTTON EUOButtonCast ; Force the Cast button to be pressed again!
  92.   }
  93. goto mainloop1
  94. ;--------------------------------------------------------------
  95. sub Setup
  96.   menu Combo Add CircleMenu First Circle
  97.   menu Combo Add CircleMenu Second Circle
  98.   menu Combo Add CircleMenu Third Circle
  99.   menu Combo Add CircleMenu Forth Circle
  100.   menu Combo Add CircleMenu Fifth Circle
  101.   menu Combo Add CircleMenu Sixth Circle
  102.   menu Combo Add CircleMenu Seventh Circle
  103.   menu Combo Add CircleMenu Eighth Circle
  104.   menu Combo Add CircleMenu Necromancy Circle
  105.   menu Combo Select CircleMenu 1 ; select 1st circle
  106.   gosub UpdateSpellMenu 1 ; redraw combo SpellMenu with 1st circle spells
  107.   menu Combo Select SpellMenu 1 ; always select the first combo select so it's visible
  108. return
  109. ;--------------------------------------------------------------
  110. sub UpdateSpellMenu
  111.   set %circle %1
  112.   menu Delete SpellMenu
  113.   menu Font BGColor White
  114.   menu Combo Create SpellMenu 12 64 145
  115.  
  116.   menu get EUOCheckOSI
  117.   set %shard_kind #MENURES ; OSI and RunUO have different spells for 1st
  118.   if %circle = 1
  119.   {
  120.     if %shard_kind = #TRUE
  121.     {
  122.       menu Combo Add SpellMenu Clumsy
  123.       menu Combo Add SpellMenu Create Food
  124.       menu Combo Add SpellMenu Feeblemind
  125.       menu Combo Add SpellMenu Heal
  126.       menu Combo Add SpellMenu Magic Arrow
  127.       menu Combo Add SpellMenu Night Sight
  128.       menu Combo Add SpellMenu Reactive Armor
  129.       menu Combo Add SpellMenu Weaken
  130.     }
  131.     else
  132.     {
  133.       menu Combo Add SpellMenu Reactive Armor
  134.       menu Combo Add SpellMenu Clumsy
  135.       menu Combo Add SpellMenu Create Food
  136.       menu Combo Add SpellMenu Feeblemind
  137.       menu Combo Add SpellMenu Heal
  138.       menu Combo Add SpellMenu Magic Arrow
  139.       menu Combo Add SpellMenu Night Sight
  140.       menu Combo Add SpellMenu Weaken
  141.     }
  142.     return
  143.   }
  144.   if %circle = 2
  145.   {
  146.     menu Combo Add SpellMenu Agility
  147.     menu Combo Add SpellMenu Cunning
  148.     menu Combo Add SpellMenu Cure
  149.     menu Combo Add SpellMenu Harm
  150.     menu Combo Add SpellMenu Magic Trap
  151.     menu Combo Add SpellMenu Magic Untrap
  152.     menu Combo Add SpellMenu Protection
  153.     menu Combo Add SpellMenu Strength
  154.   }
  155.   if %circle = 3
  156.   {
  157.     menu Combo Add SpellMenu Bless
  158.     menu Combo Add SpellMenu Fireball
  159.     menu Combo Add SpellMenu Magic Lock
  160.     menu Combo Add SpellMenu Poison
  161.     menu Combo Add SpellMenu Telekinesis
  162.     menu Combo Add SpellMenu Teleport
  163.     menu Combo Add SpellMenu Unlock
  164.     menu Combo Add SpellMenu Wall of Stone
  165.   }
  166.   if %circle = 4
  167.   {
  168.     menu Combo Add SpellMenu Arch Cure
  169.     menu Combo Add SpellMenu Arch Protection
  170.     menu Combo Add SpellMenu Curse
  171.     menu Combo Add SpellMenu Fire Field
  172.     menu Combo Add SpellMenu Greater Heal
  173.     menu Combo Add SpellMenu Lightning
  174.     menu Combo Add SpellMenu Mana Drain
  175.     menu Combo Add SpellMenu Recall
  176.   }
  177.   if %circle = 5
  178.   {
  179.     menu Combo Add SpellMenu Blade Spirits
  180.     menu Combo Add SpellMenu Dispel Field
  181.     menu Combo Add SpellMenu Incognito
  182.     menu Combo Add SpellMenu Magic Reflection
  183.     menu Combo Add SpellMenu Mind Blast
  184.     menu Combo Add SpellMenu Paralyze
  185.     menu Combo Add SpellMenu Poison Field
  186.     menu Combo Add SpellMenu Summon Creature
  187.   }
  188.   if %circle = 6
  189.   {
  190.     menu Combo Add SpellMenu Dispel
  191.     menu Combo Add SpellMenu Energy Bolt
  192.     menu Combo Add SpellMenu Explosion
  193.     menu Combo Add SpellMenu Invisibility
  194.     menu Combo Add SpellMenu Mark
  195.     menu Combo Add SpellMenu Mass Curse
  196.     menu Combo Add SpellMenu Paralyze Field
  197.     menu Combo Add SpellMenu Reveal
  198.   }
  199.   if %circle = 7
  200.   {
  201.     menu Combo Add SpellMenu Chain Lightning
  202.     menu Combo Add SpellMenu Energy Field
  203.     menu Combo Add SpellMenu Flame Strike
  204.     menu Combo Add SpellMenu Gate Travel
  205.     menu Combo Add SpellMenu Mana Vampire
  206.     menu Combo Add SpellMenu Mass Dispel
  207.     menu Combo Add SpellMenu Meteor Swarm
  208.     menu Combo Add SpellMenu Polymorph
  209.   }
  210.   if %circle = 8
  211.   {
  212.     menu Combo Add SpellMenu Earthquake
  213.     menu Combo Add SpellMenu Energy Vortex
  214.     menu Combo Add SpellMenu Resurrection
  215.     menu Combo Add SpellMenu Air Elemental
  216.     menu Combo Add SpellMenu Summon Daemon
  217.     menu Combo Add SpellMenu Earth Elemental
  218.     menu Combo Add SpellMenu Fire Elemental
  219.     menu Combo Add SpellMenu Water Elemental
  220.   }
  221.   if %circle = 9
  222.   {
  223.     menu Combo Add SpellMenu Animate Dead
  224.     menu Combo Add SpellMenu Blood Oath
  225.     menu Combo Add SpellMenu Corpse Skin
  226.     menu Combo Add SpellMenu Curse Weapon
  227.     menu Combo Add SpellMenu Evil Omen
  228.     menu Combo Add SpellMenu Horrific Beast
  229.     menu Combo Add SpellMenu Lich Form
  230.     menu Combo Add SpellMenu Mind Rot
  231.     menu Combo Add SpellMenu Pain Spike
  232.     menu Combo Add SpellMenu Poison Strike
  233.     menu Combo Add SpellMenu Strangle
  234.     menu Combo Add SpellMenu Summon Familiar
  235.     menu Combo Add SpellMenu Vampiric Embrace
  236.     menu Combo Add SpellMenu Vengeful Spirit
  237.     menu Combo Add SpellMenu Wither
  238.     menu Combo Add SpellMenu Wraith Form
  239.     menu Combo Add SpellMenu Exorcism
  240.   }
  241. return
  242. ;--------------------------------------------------------------
  243. sub UpdateLogWindow
  244.   if %jindex = N/A
  245.     set %jindex #JINDEX
  246.   if %journal_pointer = N/A
  247.     set %journal_pointer 1
  248.   if %journal_pointer > 200
  249.   {
  250.     set %journal_pointer 1
  251.     menu delete EUOListLogWindow ; remember when you want to redraw a control, you MUST!! delete it first.
  252.     menu List Create EUOListLogWindow 12 136 257 225
  253.   }
  254.   while %jindex < #JINDEX
  255.   {
  256.     scanjournal %jindex
  257.     gosub AddSpace #JOURNAL
  258.     menu List add EUOListLogWindow #RESULT
  259.     set %journal . %journal_pointer #RESULT
  260.     set %journal_pointer %journal_pointer + 1
  261.     set %jindex %jindex + 1
  262.   }
  263.  
  264. return
  265. ;--------------------------------------------------------------
  266. ; %1 - string to mung
  267. sub AddSpace
  268.   namespace push
  269.   namespace local AS
  270.   set !tempstring %1
  271.   AddSpace_loop1:
  272.     str pos !tempstring _
  273.     if #STRRES <> 0
  274.     {
  275.       set !val #STRRES - 1
  276.       str left !tempstring !val
  277.       set !left #STRRES
  278.       set !val !val + 1
  279.       str del !tempstring 1 !val
  280.       set !tempstring !left , #SPC , #STRRES
  281.       goto AddSpace_loop1
  282.     }
  283.   set #RESULT !tempstring
  284.   namespace pop
  285. return #RESULT
  286. ;--------------------------------------------------------------
  287. sub UpdateNecromancySpellMenu
  288.   menu Delete SpellMenu
  289.   menu Combo Create SpellMenu 12 20 145
  290.   menu Combo Add SpellMenu Animate Dead
  291.   menu Combo Add SpellMenu Blood Oath
  292.   menu Combo Add SpellMenu Corpse Skin
  293.   menu Combo Add SpellMenu Curse Weapon
  294.   menu Combo Add SpellMenu Evil Omen
  295.   menu Combo Add SpellMenu Horrific Beast
  296.   menu Combo Add SpellMenu Lich Form
  297.   menu Combo Add SpellMenu Mind Rot
  298.   menu Combo Add SpellMenu Pain Spike
  299.   menu Combo Add SpellMenu Poison Strike
  300.   menu Combo Add SpellMenu Strangle
  301.   menu Combo Add SpellMenu Summon Familiar
  302.   menu Combo Add SpellMenu Vampiric Embrace
  303.   menu Combo Add SpellMenu Vengeful Spirit
  304.   menu Combo Add SpellMenu Wither
  305.   menu Combo Add SpellMenu Wraith Form
  306.   menu Combo Add SpellMenu Exorcism
  307. return
  308. ;--------- EasyUO Menu Designer Code Begin ---------
  309. sub showEUOMenu1
  310.         menu Clear
  311.         menu Window Title TrailMyx's Spell Caster
  312.         menu Window Color BtnFace
  313.         menu Window Size 277 392
  314.         menu Font Transparent #true
  315.         menu Font Align Right
  316.         menu Font Name MS Sans Serif
  317.         menu Font Size 8
  318.         menu Font Style
  319.         menu Font Color WindowText
  320.         menu Font Transparent #false
  321.         menu Font Align Left
  322.         menu Text EUOLabel1 8 4 Spell circle/Necro:
  323.         menu Text EUOLabel2 8 48 Spell name:
  324.         menu Text EUOLabel3 8 120 Log Display:
  325.         menu Shape EUOShape1 168 40 105 21 3 7 1 Black 7 Lime
  326.         menu Text EUOLabel4 16 96 Delay
  327.         menu Font BGColor Window
  328.         menu Combo Create CircleMenu 12 20 145
  329.         menu Combo Create SpellMenu 12 64 145
  330.         menu List Create EUOListLogWindow 12 136 257 225
  331.         menu Font BGColor BtnFace
  332.         menu Button EUOButtonCast 184 12 75 25 Cast
  333.         menu Check EUOCheckOSI 172 64 73 17 #true OSI
  334.         menu Font BGColor Window
  335.         menu Edit EUOStatus 12 368 257 ...
  336.         menu Font BGColor BtnFace
  337.         menu Check EUOCheckLoop 172 80 93 17 #false Loop?
  338.         menu Check EUOCheckWaitForTarget 172 96 109 17 #false Wait for Target?
  339.         menu Font BGColor Window
  340.         menu Edit EUOEditDelay 48 92 81 20
  341.         menu Font BGColor BtnFace
  342.         menu Button EUOButtonResetTarget 184 116 75 21 Reset Target
  343.         menu Show 421 270
  344. return
  345. ;--------- EasyUO Menu Designer Code End ---------
  346.  

Here is a VERY simplified version of what this script does (psudocode)

Code: easyuo
  1. gosub showEUOMenu1 ; build and show showEUOMenu1 menu (generated with Menu Designer)
  2. gosub Setup ; setup menu information
  3. mainloop1:
  4.   gosub UpdateLogWindow
  5.  
  6.   [i]if MenuCircle has changed[/i]
  7.     gosub UpdateSpellMenu %current_circle
  8.  
  9.   [i]if EUOListLogWindow selection has changed
  10.     Get currently selected item in EUOListLogWindow
  11.     Set this value as text within EUOStatus [/i]
  12.  
  13.   if #MENUBUTTON = EUOButtonCast
  14.     [i]Cast the spell[/i]
  15.  
  16.   if #MENUBUTTON = EUOButtonResetTarget
  17.     set %last_target N/A
  18.  
  19.   menu get EUOCheckLoop
  20.   if #MENURES = #TRUE
  21.     set #MENUBUTTON EUOButtonCast ; force the casting of the last spell
  22.  
  23.   goto mainloop1
  24.  


So we talked about the menu, and here it is:

Quote
;--------- EasyUO Menu Designer Code Begin ---------
sub showEUOMenu1
   menu Clear
   menu Window Title TrailMyx's Spell Caster
   menu Window Color BtnFace
   menu Window Size 277 392
   menu Font Transparent #true
   menu Font Align Right
   menu Font Name MS Sans Serif
   menu Font Size 8
   menu Font Style
   menu Font Color WindowText
   menu Font Transparent #false
   menu Font Align Left
   menu Text EUOLabel1 8 4 Spell circle/Necro:
   menu Text EUOLabel2 8 48 Spell name:
   menu Text EUOLabel3 8 120 Log Display:
   menu Shape EUOShape1 168 40 105 21 3 7 1 Black 7 Lime
   menu Text EUOLabel4 16 96 Delay
   menu Font BGColor Window
   menu Combo Create CircleMenu 12 20 145
   menu Combo Create SpellMenu 12 64 145
   menu List Create EUOListLogWindow 12 136 257 225
   menu Font BGColor BtnFace
   menu Button EUOButtonCast 184 12 75 25 Cast
   menu Check EUOCheckOSI 172 64 73 17 #true OSI
   menu Font BGColor Window
   menu Edit EUOStatus 12 368 257 ...
   menu Font BGColor BtnFace
   menu Check EUOCheckLoop 172 80 93 17 #false Loop?
   menu Check EUOCheckWaitForTarget 172 96 109 17 #false Wait for Target?
   menu Font BGColor Window
   menu Edit EUOEditDelay 48 92 81 20
   menu Font BGColor BtnFace
   menu Button EUOButtonResetTarget 184 116 75 21 Reset Target
   menu Show 421 270
return
;--------- EasyUO Menu Designer Code End ---------

You can see that there are a few different menu elements that we'll need to manipulate, but there are several that will effect the script flow so we'll concentrate on:

menu combo
menu list
menu check
menu edit


First, I'll discuss a bit more of what's happening in the main loop.  For the first button item EUOButtonCast, there are some items you should be aware of.  First is that when I'm casting a spell, I change the "green" box into a "red" box.  Unfortunately with EasyUO, there's no way to change the drawing attributes of an items that's already drawn.  The only thing you can do is to delete the item, and redraw it with the correct color/font/background.  So this code:

Code: easyuo
  1.     menu delete EUOShape1
  2.     menu Shape EUOShape1 168 40 105 21 3 7 1 Black 7 Red
  3.  

will delete the "green" box and redraw the box as "red"  It's IMPORTANT to say again that you should always delete the existing item, otherwise you'll be accumulating unused drawing objects in your UI which will impact your performance and possibily crash EasyUO in time.

The next important point I'd like to make here is that every time you handle a valid #MENUBUTTON press, you should reset the #MENUBUTTON value to some unknown value.  I generally use "N/A" and I do this right after the condition:

Code: easyuo
  1.   if #MENUBUTTON = EUOButtonCast
  2.   {
  3.     set #MENUBUTTON N/A ; Always remember to reset #MENUBUTTON when you handle it!
  4. ...
  5.  

When you are looking at controls on the UI, there's only one method you can retrieve information from them (2 if you include buttons).  #MENURES holds the value of any "menu get" command issued.  So this code:

Code: easyuo
  1.     menu get CircleMenu
  2.     set %circle #MENURES
  3.     menu get SpellMenu
  4.     set %spell #MENURES
  5.     menu get EUOCheckWaitForTarget
  6.     set %waitfortarget #MENURES
  7.  

Retrieves the values of the ComboBoxes CircleMenu and SpellMenu as well as the CheckBox EUOCheckWaitForTarget.  ListBox and ComboBox #MENURES values start at 1 for the first selection and so forth.  A #MENURES of 0 means there's nothing selected

But you see in the above code, we have to read the value of the control, then store that value in a variable in order to check more than one control at a time.

Dynamic UI Information

You'll notice when you run this script, that when you change the Circle number, you change the menu selections for the SpellMenu.  I've included this function because there are some annoying quirks to using ComboBoxes and ListBoxes within EasyUO.  These are the quirks I'm talking about:

1) You cannot read the text from a Combo/List box, only the index
2) You cannot DELETE an item from a Combo/List box. 

The second one is totally annoying when you are trying to manipulate the contents of one of these Boxes.  In order to delete information from a Combo/List box, you have to completely re-draw the entire control.  Yes, you have to delete it, and then add back all the information that was originally contained but omitting the information you wanted to delete.  Kinda dumb?  Yes, I think so to.  However, it's what we have to work with, so I have implemented code in this sample script to help you understand that.

Here is how you first add information to a List/Combo box:

Code: easyuo
  1.   menu Combo Add CircleMenu First Circle
  2.   menu Combo Add CircleMenu Second Circle
  3.   menu Combo Add CircleMenu Third Circle
  4.   menu Combo Add CircleMenu Forth Circle
  5.   menu Combo Add CircleMenu Fifth Circle
  6.   menu Combo Add CircleMenu Sixth Circle
  7.   menu Combo Add CircleMenu Seventh Circle
  8.   menu Combo Add CircleMenu Eighth Circle
  9.   menu Combo Add CircleMenu Necromancy Circle
  10.   menu Combo Select CircleMenu 1 ; select 1st circle
  11. ...
  12.  

Using a script, you can select which item in the list you want to have highlighted with the "menu Combo Select ControlName" command.  Otherwise this value will be zero and you won't have an item selected until you do it by hand during script execution.

In the sub UpdateSpellMenu function, you can see what I'm talking about when you have to redraw a List/Combo control with different information:

Code: easyuo
  1.   menu Delete SpellMenu
  2.  
  3.   menu Font BGColor White
  4.   menu Combo Create SpellMenu 12 64 145
  5.  
  6.   menu get EUOCheckOSI
  7.   set %shard_kind #MENURES ; OSI and RunUO have different spells for 1st
  8.   if %circle = 1
  9.   {
  10.     if %shard_kind = #TRUE
  11.     {
  12.       menu Combo Add SpellMenu Clumsy
  13.       menu Combo Add SpellMenu Create Food
  14.       menu Combo Add SpellMenu Feeblemind
  15.       menu Combo Add SpellMenu Heal
  16.       menu Combo Add SpellMenu Magic Arrow
  17.       menu Combo Add SpellMenu Night Sight
  18.       menu Combo Add SpellMenu Reactive Armor
  19.       menu Combo Add SpellMenu Weaken
  20.     }
  21. ...
  22.  

We delete the whole control SpellMenu:
Code: easyuo
  1.   menu Delete SpellMenu
  2.  

then create another exact copy with the same dimensions:
Code: easyuo
  1.  menu Combo Create SpellMenu 12 64 145
  2.  

Then you just add the information back that you want to be included in the control.

You'll notice that this script logs anything that happens in the journal to the EUOListLogWindow ListBox.  The function UpdateLogWindow also maintains a record of the text contained in this list box since the ListBox control doesn't do this for you.  That way, when you click of of the items in the EUOListLogWindow control, that value is copied to the EUOStatus EditBox.

Code: easyuo
  1. ;--------------------------------------------------------------
  2. sub UpdateLogWindow
  3.   if %jindex = N/A
  4.     set %jindex #JINDEX
  5.   if %journal_pointer = N/A
  6.     set %journal_pointer 1
  7.   if %journal_pointer > 200
  8.   {
  9.     set %journal_pointer 1
  10.     menu delete EUOListLogWindow ; remember when you want to redraw a control, you MUST!! delete it first.
  11.     menu List Create EUOListLogWindow 12 136 257 225
  12.   }
  13.   while %jindex < #JINDEX
  14.   {
  15.     scanjournal %jindex
  16.     gosub AddSpace #JOURNAL
  17.     menu List add EUOListLogWindow #RESULT
  18.     set %journal . %journal_pointer #RESULT
  19.     set %journal_pointer %journal_pointer + 1
  20.     set %jindex %jindex + 1
  21.   }
  22. return
  23.  

I hold the information that's shown in the journal in an array starting at index 0.  I only hold 200 entries, then start over again.  Specifically, that's what this code does:

Code: easyuo
  1.     scanjournal %jindex
  2.     gosub AddSpace #JOURNAL
  3.     menu List add EUOListLogWindow #RESULT
  4.     set %journal . %journal_pointer #RESULT
  5.     set %journal_pointer %journal_pointer + 1
  6.     set %jindex %jindex + 1
  7.  

And you get a data structure like this:

Quote
%journal0 <- Journal entry 0
%journal1 <- Journal entry 1
%journal2 <- Journal entry 2
...

I make a call to AddSpace because the information contained in the #JOURNAL system variable containes underscores and not spaces, so AddSpace converts the underscores to spaces so they look better contained in the ListBox and EditBox.  One thing to keep in mind at this point is:

1) #JOURNAL contains "_" for spaces
2) #PROPERTY contains spaces. 

It's common for the programmer to forget this, so be sure you remember this when you are doing string comparisons between #JOURNAL and #PROPERTY entries.
« Last Edit: March 01, 2017, 07:48:53 PM by TrailMyx »
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline valen2.0

  • Full Member
  • ***
  • Posts: 229
  • Activity:
    0%
  • Reputation Power: 3
  • valen2.0 has no influence.
  • Respect: +63
  • Referrals: 0
    • View Profile
Re: Creating a user interface, step by step
« Reply #1 on: August 27, 2016, 09:44:06 PM »
+1
I cannot get that program to work that you posted to create a UI. is it broke?

Offline The Ghost

  • Elite
  • *
  • *
  • Posts: 1917
  • Activity:
    0%
  • Reputation Power: 25
  • The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.
  • Respect: +245
  • Referrals: 0
    • View Profile
Re: Creating a user interface, step by step
« Reply #2 on: August 28, 2016, 06:17:47 AM »
+1
It work perfectly.  Not sure what broken. 

This is not design to get you fighting monster. It an example on how to build a menu and how to use it.

Offline valen2.0

  • Full Member
  • ***
  • Posts: 229
  • Activity:
    0%
  • Reputation Power: 3
  • valen2.0 has no influence.
  • Respect: +63
  • Referrals: 0
    • View Profile
Re: Creating a user interface, step by step
« Reply #3 on: August 28, 2016, 06:55:46 AM »
+1
I was more talking about easyuo design program. But I figured it out.

Offline The Ghost

  • Elite
  • *
  • *
  • Posts: 1917
  • Activity:
    0%
  • Reputation Power: 25
  • The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.
  • Respect: +245
  • Referrals: 0
    • View Profile
Re: Creating a user interface, step by step
« Reply #4 on: August 28, 2016, 07:19:23 AM »
+1
can be tricky to run the first time.

Offline TrailMyxTopic starter

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13301
  • Activity:
    0%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: Creating a user interface, step by step
« Reply #5 on: August 28, 2016, 10:45:17 AM »
+1
can be tricky to run the first time.

Sorry was away in Vegas this weekend.  Seems to work OK even after 7 years, so I'm not sure what you're having problems with.  Make sure you cut/paste the entire "snippet". You may have missed some code.
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline valen2.0

  • Full Member
  • ***
  • Posts: 229
  • Activity:
    0%
  • Reputation Power: 3
  • valen2.0 has no influence.
  • Respect: +63
  • Referrals: 0
    • View Profile
Re: Creating a user interface, step by step
« Reply #6 on: August 28, 2016, 12:34:12 PM »
+1
I believe I figured it out. The design program only works with the old easy uo. I have since made a template for a script and am working on implementing.

Tags: