• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

LCS - Letterbox Choose System v1.3

This bundle is marked as useful / simple. Simplicity is bliss, low effort and/or may contain minor bugs.
  • Like
Reactions: -ToasT
The Letterbox Choose System, creates a Letterbox (like Cinematicmode) with Options you can choose.
It is written in vJass, so you need JNGP for it.
I hope that it is leakfree and MUI, I have not tested it's MUI...ness ? Oo

Here is a list of the functions:
JASS:
FUNCTIONS WHICH YOU CAN USE:

call LCSShow(<integer>, <unit>, <string>)
-> It Shows one Player the "LCS"-Menu.
- integer is the Player you want to show the LCS-Screen. (Lets the Interface Disappear!)
- unit is which unit "talks" to the Player. In RPG i would pick the MainHero.
- string is the Unit name.


call LCSClear(<integer>, <boolean>)   
-> it clears the LCS for an specific player. 
- integer is the Player whichs LCS-Screen should be Cleared.
- when the boolean is true it will clear all, else it will let the extra things, it is perfect for complex things, like the Altar

call LCSOptionAdd(<integer>, <string>, <string>)
-> It Adds an option to the LCS of an specific player.
- integer is the Player you want to Show the Text.
- string is the Text displayed.
- string is the Function which is executed when the option is choosen.

call LCSRem(<integer>)
-> removes the LCS for an player, the interface is showen again, the LCS is cleared for that player and thats all :)
- integer is the Player whichs LCS-Screen should be removed.

call LCSOptionClear(<integer>, <integer>)
-> removes one single option for one player.
- integer is the player for whom the option is removed
- integer is the option id which is removed

call LCSGetPicked()
-> returns the last choosen optionid

call LCSOptionChange(<integer>, <integer>, <string>, <boolean>, <string>)
-> changes the text and/or the function of an option
- integer is the player for whom the option is changed
- integer is the option id of the option which is changed
- string is the new name of the option. Use "" when you dont want to change the function.
- boolean is true if an function shall be executed, false when nothing shall happen
- string is the new function, when boolean is true. Use "" when you dont want to change the function.

call LCSFakeAdd(<integer>, <string>)
-> Adds an text which cannot be selected to the LCS for an specific player.
- integer is the player for whom the text is shown.
- string is the text shown.

You also can change some settings:
- When you've selected the last option and press "down", do you want to return to the top?
- The highlighting color of the selected option
- When the user has choosen an option the LCS-Mode is turned off?
- Exits the LCS when pressing Escape?
- Up/Down - Sound
- Choosen - Sound
- Fadein/out delay

The map contains 5 examples how you could use it
Sorry for bad englisch.

Last but not least the code:
JASS:
/////////////////////////////////////////////////////
//          Letterbox Choose System                //
//                     by: McThyzer                //
//                                                 //
//        v1.3                                     //
//                                                 //
//   Give Credits if you use!                      //
//         If you have ideas or found buggs...     //
//  inWc: vol-lol                                  //
//        Hive: McDoNaLdGaNgStA                    //
//                                                 //
/////////////////////////////////////////////////////

library LCS initializer init
    globals
        private boolean repeating = true //when you've selected the last option and press "down", do you want to return to the start?
        private string highlighting = "|cffff9900" //the highlighting color of the selected option
        private boolean autoclose = false //When the user has choosen an option the LCS-Mode is turned off?
        private boolean exitwhenesc = true //Exits the LCS when pressing Escape?
        private sound updownsound = CreateSound("Sound\\Interface\\MouseClick1.wav", false, false, false, 10, 10, "") //just a "click" sound :)
        private sound rightsound = CreateSound("Sound\\Interface\\BigButtonClick.wav", false, false, false, 10, 10, "") //just a "click" sound :)
        private real delay = 0.5 //in what time does the interface fadein/out
    
        private hashtable HTstr = InitHashtable()  //Saves the Strings and Messages for each player
        private hashtable HTfun = InitHashtable() // Saves the Functions which are executed.
        private hashtable HTex = InitHashtable() // For extra stuff (like "Which String is marked?")
        private hashtable HTfun2 = InitHashtable() //Saves the Functions for the "left" key.
        public integer LCSLastPickedOptionId = 0
    endglobals
    
    private function LCSString takes integer whichplayer returns string
        local string str = ""
        local integer i = 1
        
        if LoadInteger(HTex, whichplayer, 0) > 4 then
            set i = LoadInteger(HTex, whichplayer, 0) - 4
        endif
        
        loop
            exitwhen i > LoadInteger(HTstr, whichplayer, 0)
                        
            if i == LoadInteger(HTex, whichplayer, 0) then
                set str = str + highlighting
            endif
            
            set str = str + LoadStr(HTstr, whichplayer, i)
            
            if i == LoadInteger(HTex, whichplayer, 0) then
                set str = str + "|r"
            endif
            
            set str = str + "|n"
            
            set i = i + 1
        endloop
        
        return str
    endfunction
    
    private function LCSOn takes nothing returns boolean
        return LoadBoolean(HTex, GetPlayerId(GetTriggerPlayer()), 3)
    endfunction
    
    function LCSClear takes integer whichplayer, boolean all returns nothing
        local integer i = 1
        loop
            exitwhen i > LoadInteger(HTstr, whichplayer, 0)
            call SaveStr(HTstr, whichplayer, i, "")
            call SaveStr(HTfun, whichplayer, i, "")
            set i = i + 1
        endloop
        call SaveInteger(HTstr, whichplayer, 0, 0)
        call SaveInteger(HTex, whichplayer, 0, 1)
        if all == true then
            call SaveUnitHandle(HTex, whichplayer, 1, null)
            call SaveStr(HTex, whichplayer, 2, "")
        endif
    endfunction
    
    private function LCSTextReset takes integer whichplayer returns nothing
        local string str = LCSString(whichplayer)            
        call TransmissionFromUnitWithNameBJ( bj_FORCE_PLAYER[whichplayer], LoadUnitHandle(HTex, whichplayer, 1), LoadStr(HTex, whichplayer, 2), null, str, bj_TIMETYPE_SET, 9999, false)
        
        loop
            exitwhen LoadStr(HTfun, whichplayer, LoadInteger(HTex, whichplayer, 0)) != "lcsfake"
            call SaveInteger(HTex, whichplayer, 0, LoadInteger(HTex, whichplayer, 0) + 1)
        endloop
        
    endfunction
    
    function LCSOptionChange takes integer whichplayer, integer option, string newtext, boolean exefunc, string newfunc1, string newfunc2 returns nothing
        if newtext != "" then        
            call SaveStr(HTstr, whichplayer, option, newtext)
        endif
        
        if exefunc == false then
            call SaveStr(HTfun, whichplayer, option, null)
        else
            if newfunc1 != "" then
                call SaveStr(HTfun, whichplayer, option, newfunc1)
            endif
            if newfunc2 != "" then
                call SaveStr(HTfun2, whichplayer, option, newfunc2)
            endif
        endif
        
        call LCSTextReset(whichplayer)
    endfunction
    
    function LCSOptionClear takes integer whichplayer, integer option returns nothing
        local integer i = option
        local integer amount = LoadInteger(HTstr, whichplayer, 0) - 1
        
        loop
            exitwhen i > amount
            call SaveStr(HTstr, whichplayer, i, LoadStr(HTstr, whichplayer, i + 1))
            call SaveStr(HTfun, whichplayer, i, LoadStr(HTfun, whichplayer, i + 1))
            call SaveStr(HTfun2, whichplayer, i, LoadStr(HTfun2, whichplayer, i + 1))
            set i = i + 1
        endloop
        
        call SaveInteger(HTstr, whichplayer, 0, amount)
        call LCSTextReset(whichplayer)
    endfunction
    
    function LCSRem takes integer whichplayer returns nothing
        call LCSClear(whichplayer, true)
        if GetLocalPlayer() == Player(whichplayer) then
            call ShowInterface(true, delay)
            call PanCameraTo(GetUnitX(LoadUnitHandle(HTex, whichplayer, 1)),GetUnitY(LoadUnitHandle(HTex, whichplayer, 1)))
        endif
        call SaveBoolean(HTex, whichplayer, 3, false)
    endfunction
    
    function LCSShow takes integer whichplayer, unit hero, string name returns nothing
        call LCSClear(whichplayer, true)
        
        if GetLocalPlayer() == Player(whichplayer) then
            call ClearTextMessages()
            call ShowInterface(false, delay)
            call EnableUserControl(true)
        endif
        
        call SetCameraTargetControllerNoZForPlayer(Player(whichplayer), hero, 0, 0, false)
                
        call SaveUnitHandle(HTex, whichplayer, 1, hero)
        call SaveStr(HTex, whichplayer, 2, name)
        call SaveBoolean(HTex, whichplayer, 3, true)
            
        call LCSTextReset(whichplayer)
        set hero = null
    endfunction
    
    function lcsfake takes nothing returns nothing
    endfunction
    
    function LCSOptionAdd takes integer whichplayer, string text, string funcName, string leftfunc returns nothing
        local integer i = LoadInteger(HTstr, whichplayer, 0) + 1
        
        call SaveStr(HTstr, whichplayer, i, text)
        call SaveStr(HTfun, whichplayer, i, funcName)
        call SaveStr(HTfun2, whichplayer, i, leftfunc)
        
        if leftfunc == "" then
            call SaveStr(HTfun2, whichplayer, i, null)
        endif
        
        call SaveInteger(HTstr, whichplayer, 0, i)
        if LCSOn() == true then
            call LCSTextReset(whichplayer)
        endif
    endfunction
    
    function LCSFakeAdd takes integer whichplayer, string text returns nothing
        local integer i = LoadInteger(HTstr, whichplayer, 0) + 1
        
        call SaveStr(HTstr, whichplayer, i, text)
        call SaveStr(HTfun, whichplayer, i, "lcsfake")
        
        call SaveInteger(HTstr, whichplayer, 0, i)
        if LCSOn() == true then
            call LCSTextReset(whichplayer)
        endif
    endfunction
    
    private function up takes nothing returns nothing
        local integer i = LoadInteger(HTex, GetPlayerId(GetTriggerPlayer()), 0)
        
        if (GetLocalPlayer() == GetTriggerPlayer()) then
            call StartSound( updownsound )
        endif
                
        if i == 1 and repeating == true then
            set i = LoadInteger(HTstr, GetPlayerId(GetTriggerPlayer()), 0)
        elseif i == 1 and repeating == false then
            set i = i
        elseif i > 1 then
            set i = i - 1
        endif
        
        if LoadStr(HTfun, GetPlayerId(GetTriggerPlayer()), i) == "lcsfake" then
            set i = i - 1
            if i == 0 and repeating == true then
                set i = LoadInteger(HTstr, GetPlayerId(GetTriggerPlayer()), 0)
            endif
        endif
        
        call SaveInteger(HTex, GetPlayerId(GetTriggerPlayer()), 0, i)
        call LCSTextReset(GetPlayerId(GetTriggerPlayer()))
    endfunction
    
    private function down takes nothing returns nothing
        local integer i = LoadInteger(HTex, GetPlayerId(GetTriggerPlayer()), 0)
        
        if (GetLocalPlayer() == GetTriggerPlayer()) then
            call StartSound( updownsound )
        endif
        
        if i == LoadInteger(HTstr, GetPlayerId(GetTriggerPlayer()), 0) and repeating == true then
            set i = 1
        elseif i == LoadInteger(HTstr, GetPlayerId(GetTriggerPlayer()), 0) and repeating == false then
            set i = i
        elseif i < LoadInteger(HTstr, GetPlayerId(GetTriggerPlayer()), 0) then
            set i = i + 1
        endif
        
        if LoadStr(HTfun, GetPlayerId(GetTriggerPlayer()), i) == "lcsfake" then
            set i = i + 1
            if i == LoadInteger(HTstr, GetPlayerId(GetTriggerPlayer()), 0) and repeating == true then
                set i = 1
            endif
        endif
        
        call SaveInteger(HTex, GetPlayerId(GetTriggerPlayer()), 0, i)
        call LCSTextReset(GetPlayerId(GetTriggerPlayer()))
    endfunction
    
    function LCSGetPicked takes nothing returns integer 
        return LCSLastPickedOptionId
    endfunction
    
    private function right takes nothing returns nothing
        set LCSLastPickedOptionId = LoadInteger(HTex, GetPlayerId(GetTriggerPlayer()), 0)
        if LoadStr(HTfun, GetPlayerId(GetTriggerPlayer()), LoadInteger(HTex, GetPlayerId(GetTriggerPlayer()), 0)) != null then
            call ExecuteFunc(LoadStr(HTfun, GetPlayerId(GetTriggerPlayer()), LoadInteger(HTex, GetPlayerId(GetTriggerPlayer()), 0)))
        endif
        
        if (GetLocalPlayer() == GetTriggerPlayer()) then
            call StartSound( rightsound )
        endif
        
        if autoclose == true then
            call LCSRem(GetPlayerId(GetTriggerPlayer()))
        endif
    endfunction
    
    private function left takes nothing returns nothing        
        if LoadStr(HTfun2, GetPlayerId(GetTriggerPlayer()), LoadInteger(HTex, GetPlayerId(GetTriggerPlayer()), 0)) != null then
            set LCSLastPickedOptionId = LoadInteger(HTex, GetPlayerId(GetTriggerPlayer()), 0)
            call ExecuteFunc(LoadStr(HTfun2, GetPlayerId(GetTriggerPlayer()), LoadInteger(HTex, GetPlayerId(GetTriggerPlayer()), 0)))
            if (GetLocalPlayer() == GetTriggerPlayer()) then
                call StartSound( rightsound )
            endif
            
            if autoclose == true then
                call LCSRem(GetPlayerId(GetTriggerPlayer()))
            endif
        endif
    endfunction
    
    private function esc takes nothing returns nothing
        local integer id = GetPlayerId(GetTriggerPlayer())
        if exitwhenesc == true then
            call LCSRem(id)
        else
             call PolledWait(0.01)
            call LCSTextReset(id)
        endif
    endfunction
    
    private function init takes nothing returns nothing
        local trigger LCSup = CreateTrigger()
        local trigger LCSdown = CreateTrigger()
        local trigger LCSright = CreateTrigger()
        local trigger LCSleft = CreateTrigger()
        local trigger LCSEsc = CreateTrigger()
        local integer i = 0
        
        loop
            exitwhen i > 12
            call TriggerRegisterPlayerKeyEventBJ( LCSup, Player(i), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_UP )
            call TriggerRegisterPlayerKeyEventBJ( LCSdown, Player(i), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_DOWN )
            call TriggerRegisterPlayerKeyEventBJ( LCSright, Player(i), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_RIGHT )
            call TriggerRegisterPlayerKeyEventBJ( LCSleft, Player(i), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_LEFT )
            call TriggerRegisterPlayerEvent(LCSEsc, Player(i), EVENT_PLAYER_END_CINEMATIC)
            call SaveBoolean(HTex, i, 3, false)
            set i = i + 1
        endloop
        
        call TriggerAddCondition(LCSup, Condition(function LCSOn))
        call TriggerAddCondition(LCSdown, Condition(function LCSOn))
        call TriggerAddCondition(LCSright, Condition(function LCSOn))
        call TriggerAddCondition(LCSleft, Condition(function LCSOn))
        call TriggerAddCondition(LCSEsc, Condition(function LCSOn))
        call TriggerAddAction(LCSup, function up)
        call TriggerAddAction(LCSdown, function down)
        call TriggerAddAction(LCSright, function right)
        call TriggerAddAction(LCSleft, function left)
        call TriggerAddAction(LCSEsc, function esc)
    endfunction
endlibrary

JASS:
/////////////////////////////////////////////////////////////////////////////////////////////////////
- Letterbox Choose System v1.1 -

- Changed description to a better one
- Changed "AddText" to "AddOption"
- Fixed an bugg that occurs when pressing the 'Esc' key while LCS is on.
- Added an feature: "exitwhenesc", when it is true and a player presses esc, the LCS will close, else nothing will happen
- Added a function "LCSOptionClear" for clearing a single Option.
- Added a function "LCSOptionChange" for changing the text and/or the function of an option

/////////////////////////////////////////////////////////////////////////////////////////////////////
- Letterbox Choose System v1.2 -

- Added "Revive" to the Altar
- Improved the "Troll spawner" trigger
- Added "Dialog" example. (Clockwerk Goblin, bottom left)

/////////////////////////////////////////////////////////////////////////////////////////////////////
- Letterbox Choose System v1.3 -

- Improved the "LCSOptionAdd" function to add an trigger which is executed when pressing the "left" key.
- Improved the "LCSOptionChange" function to change the "left"-key trigger
- Added a function "LCSFakeAdd" to add an text which cannot be selected.

When you found a Leak/Bugg/Idea to Improve tell it to me please :)
- Is it MUI?

Keywords:
letterbox, choose, dialog, keyboard, dialogue, conversation, talk, multiple choice, choice, multiple, system
Contents

Letterbox Choose System (Map)

Reviews
11:31, 21st Dec 2009 TriggerHappy: Review for Spell This system seems very hard to configure, by looking at your examples the user has to do most of the code and it's very confusing. I'm not sure whether to approve this or not, because...

Moderator

M

Moderator

11:31, 21st Dec 2009
TriggerHappy:

Review for Spell

This system seems very hard to configure, by looking at your examples
the user has to do most of the code and it's very confusing. I'm not
sure whether to approve this or not, because the idea is great but the
coding is fairly amateur.
  • SetCameraTargetControllerNoZForPlayer -- Useless BJ.
  • PolledWait -- Bad.
  • I really dislike your use of ExecuteFunc, use .execute or something.

Status

Feel free to message me here if you have any issues with
my review or if you have updated your resource and want it reviewed again.

Rejected
 
Level 4
Joined
Oct 17, 2008
Messages
35
looks interesting ill have to dl and test

EDIT: The demo was very fun :) and this is not what i expected this is very original and creative use of the cinimatic mode that most people wouldnt think of +rep
 
Last edited:
Level 3
Joined
Feb 23, 2009
Messages
16
Thank you ;).

I forgot in the description to ask for ideas how i could fix the bugg, that happens when "exit LCS when pressing esc" is false.
Then it takes a short time until the screen is back.
And the wait between it is needed.
Some one know a workaround?

New version, changelog is in description!
 
Last edited:
Top