Results 1 to 20 of 20

Thread: Miniscript to hide/unhide stratmap-ui whilst ingame

  1. #1
    Userpro's Avatar =RAE= HostedMod Creator
    Join Date
    Jul 2008
    Location
    regno germanicum, teutonical forest
    Posts
    1,672

    Default Miniscript to hide/unhide stratmap-ui whilst ingame

    This little first-time-feature script is able to hide & unhide the entire stratmap user interface by simply pressing the "SCROLL_LOCK key" whilst ingame on the stratmap.
    I've initally created this nice script only, to make better campaign-map screenshots for our mod. But i think some people out there would appreciate, to add this little feature in their game, also to increase the overall visibility on the stratmap, so i decided to make it public.

    But
    if anybody would like to use this inedited feature in a public mod, it would be only sane, to leave a little note and/or credit, maybe in favour to our RAE-mod, or the RAE-team (see signature), coz our mod is still in development and this script its a inherent part of it!
    ______________________________

    Add the following little piece of lines to your campaign_script.txt located in ...
    X:\Games\Medieval II TotalWar\mods\your-mod\data\world\maps\campaign\imperial_campaign\


    Code:
    declare_counter ui_showing
    monitor_event ShortcutTriggered ShortcutTriggered object_manager hide_gui
            wait 0.1
                if I_CompareCounter ui_showing = 0
                    hide_ui
                    disable_movie_view
                    set_counter ui_showing 2
                end_if
                if I_CompareCounter ui_showing = 1
                    show_ui
                    set_counter ui_showing 0
                end_if
                if I_CompareCounter ui_showing = 2
                    set_counter ui_showing 1
                end_if
        end_monitor
    Not savegame compatible!



    Last edited by Userpro; May 05, 2010 at 08:36 AM.
    Visit our TWC M2TW-Kingdoms Hosted Mods Forum for...

    !!! RAE Development stopped --- read last Statement here !!!
    M2TW-Kingdoms Mod Creator REDEO AD EXORDIUM ( RAE )
    Progress: 95% internal final beta release - 85% official release
    RAE TWC-Wiki Eagle Standard interview ... RAE.net Homepage ... RAE TWZ-Germany
    Proudly Sega & Steam Boycotter since ETW! See why here or this petition
    Sorry for bad english here, there and in my tutorials > advanced horde invasion & hide/unhide stratmap-ui & Beginners modding



  2. #2
    Squid's Avatar Opifex
    Patrician Artifex Technical Staff

    Join Date
    Feb 2007
    Location
    Frozen waste lands of the north
    Posts
    17,736
    Blog Entries
    3

    Default Re: Miniscript to hide/unhide stratmap-ui whilst ingame

    You can simplify it as follows:

    Code:
     monitor_event ShortcutTriggered ShortcutTriggered object_manager hide_gui
          wait 0.5
          if I_CompareCounter ui_showing = 1
               hide_ui
               disable_movie_view
               set_counter ui_showing 0
          end_if
           if I_CompareCounter ui_showing = 0
               show_ui
               set_counter ui_showing 1
           end_if
    end_monitor
    Since counters start with a value of 0, the first time the monitor is triggered the ui will appear, the second time the monitor is triggered the ui will disappear. You may actually want to swap the disappear and reappear commands as right now scroll lock needs to be pressed twice to see a change.
    Under the patronage of Roman_Man#3, Patron of Ishan
    Click for my tools and tutorials
    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe." -----Albert Einstein

  3. #3
    Userpro's Avatar =RAE= HostedMod Creator
    Join Date
    Jul 2008
    Location
    regno germanicum, teutonical forest
    Posts
    1,672

    Default Re: Miniscript to hide/unhide stratmap-ui whilst ingame

    Quote Originally Posted by Sqυιd View Post
    You can simplify it as follows:

    Spoiler Alert, click show to read: 
    Code:
     monitor_event ShortcutTriggered ShortcutTriggered object_manager hide_gui
          wait 0.5
          if I_CompareCounter ui_showing = 1
               hide_ui
               disable_movie_view
               set_counter ui_showing 0
          end_if
           if I_CompareCounter ui_showing = 0
               show_ui
               set_counter ui_showing 1
           end_if
    end_monitor
    Since counters start with a value of 0, the first time the monitor is triggered the ui will appear, the second time the monitor is triggered the ui will disappear. You may actually want to swap the disappear and reappear commands as right now scroll lock needs to be pressed twice to see a change.
    This one will not work, Sqυιd. Coz if you set counter to 0 in the first "if" condition, the next "if" condition will also apply - and doing so in the same monitor event, they will annul each other.
    Not for nothing my above script is a bit more wilier (and looks a bit more chaotic).


    Added:
    I forgot to add the declare counter line. I've caught it up now!
    Last edited by Userpro; November 10, 2009 at 06:48 PM.
    Visit our TWC M2TW-Kingdoms Hosted Mods Forum for...

    !!! RAE Development stopped --- read last Statement here !!!
    M2TW-Kingdoms Mod Creator REDEO AD EXORDIUM ( RAE )
    Progress: 95% internal final beta release - 85% official release
    RAE TWC-Wiki Eagle Standard interview ... RAE.net Homepage ... RAE TWZ-Germany
    Proudly Sega & Steam Boycotter since ETW! See why here or this petition
    Sorry for bad english here, there and in my tutorials > advanced horde invasion & hide/unhide stratmap-ui & Beginners modding



  4. #4
    The Border Reiver's Avatar Artifex
    Patrician

    Join Date
    Feb 2006
    Location
    Australia
    Posts
    3,692

    Default Re: Miniscript to hide/unhide stratmap-ui whilst ingame

    Brilliant job Userpro, I always wondered why this wasn't a default option in MTW2. Rep +

    I will add this to my mod for when I test!

  5. #5
    Squid's Avatar Opifex
    Patrician Artifex Technical Staff

    Join Date
    Feb 2007
    Location
    Frozen waste lands of the north
    Posts
    17,736
    Blog Entries
    3

    Default Re: Miniscript to hide/unhide stratmap-ui whilst ingame

    Quote Originally Posted by Userpro View Post
    This one will not work, Sqυιd. Coz if you set counter to 0 in the first "if" condition, the next "if" condition will also apply - and doing so in the same monitor event, they will annul each other.
    Not for nothing my above script is a bit more wilier (and looks a bit more chaotic).


    Added:
    I forgot to add the declare counter line. I've caught it up now!
    You're right I was missing a counter for the if statements. The other thing you're missing is having movie view re-enabled. Currently you are disabling it, but have no mechanism for re-enabling it.

    Code:
    declare_counter ui_showing
    declare_counter ui_changed
    monitor_event ShortcutTriggered ShortcutTriggered object_manager hide_gui
        wait 0.5
        set_counter ui_changed = 0
        if I_CompareCounter ui_showing = 0
             hide_ui
             disable_movie_view
             set_counter ui_showing 0
             set_counter ui_changed 1
        end_if
        if I_CompareCounter ui_showing = 1 and I_CompareCounter ui_changed = 0
             show_ui
             set_counter ui_showing 1
        end_if
    end_monitor
    Under the patronage of Roman_Man#3, Patron of Ishan
    Click for my tools and tutorials
    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe." -----Albert Einstein

  6. #6
    Userpro's Avatar =RAE= HostedMod Creator
    Join Date
    Jul 2008
    Location
    regno germanicum, teutonical forest
    Posts
    1,672

    Default Re: Miniscript to hide/unhide stratmap-ui whilst ingame

    I think that nobody will miss the "black movie mode restriction bars" and after re-enabling the ui, it seems that the restriction bars will re-appear automatically. This could be the response of a non-existing "enable_movie_view" counterpart command.
    Last edited by Userpro; November 10, 2009 at 07:27 PM.
    Visit our TWC M2TW-Kingdoms Hosted Mods Forum for...

    !!! RAE Development stopped --- read last Statement here !!!
    M2TW-Kingdoms Mod Creator REDEO AD EXORDIUM ( RAE )
    Progress: 95% internal final beta release - 85% official release
    RAE TWC-Wiki Eagle Standard interview ... RAE.net Homepage ... RAE TWZ-Germany
    Proudly Sega & Steam Boycotter since ETW! See why here or this petition
    Sorry for bad english here, there and in my tutorials > advanced horde invasion & hide/unhide stratmap-ui & Beginners modding



  7. #7
    Squid's Avatar Opifex
    Patrician Artifex Technical Staff

    Join Date
    Feb 2007
    Location
    Frozen waste lands of the north
    Posts
    17,736
    Blog Entries
    3

    Default Re: Miniscript to hide/unhide stratmap-ui whilst ingame

    Moved to text editing and scripting.
    Under the patronage of Roman_Man#3, Patron of Ishan
    Click for my tools and tutorials
    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe." -----Albert Einstein

  8. #8
    Userpro's Avatar =RAE= HostedMod Creator
    Join Date
    Jul 2008
    Location
    regno germanicum, teutonical forest
    Posts
    1,672

    Default Re: Miniscript to hide/unhide stratmap-ui whilst ingame

    Thanks Squid.
    I would like to point out that i edited slightly the above script to identify the very first key-stroke immediately!
    Last edited by Userpro; November 10, 2009 at 12:00 PM.
    Visit our TWC M2TW-Kingdoms Hosted Mods Forum for...

    !!! RAE Development stopped --- read last Statement here !!!
    M2TW-Kingdoms Mod Creator REDEO AD EXORDIUM ( RAE )
    Progress: 95% internal final beta release - 85% official release
    RAE TWC-Wiki Eagle Standard interview ... RAE.net Homepage ... RAE TWZ-Germany
    Proudly Sega & Steam Boycotter since ETW! See why here or this petition
    Sorry for bad english here, there and in my tutorials > advanced horde invasion & hide/unhide stratmap-ui & Beginners modding



  9. #9
    Gigantus's Avatar The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it
    Patrician Moderator Emeritus Administrator Emeritus Modding Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    46,896
    Blog Entries
    24

    Default Re: Miniscript to hide/unhide stratmap-ui whilst ingame

    That is going to enhance screen shots tremendously!



  10. #10
    Userpro's Avatar =RAE= HostedMod Creator
    Join Date
    Jul 2008
    Location
    regno germanicum, teutonical forest
    Posts
    1,672

    Default Re: Miniscript to hide/unhide stratmap-ui whilst ingame

    If anybody would like to use this inedited feature in a public mod, it would be only sane, to leave a little note and/or credit, maybe in favour to our RAE-mod, or the RAE-team (see signature), coz our mod is still in development and this script its a inherent part of it!
    That is going to enhance screen shots tremendously!
    That was initaly the basic reason to create this little jewel.
    Last edited by Userpro; November 11, 2009 at 07:02 PM.
    Visit our TWC M2TW-Kingdoms Hosted Mods Forum for...

    !!! RAE Development stopped --- read last Statement here !!!
    M2TW-Kingdoms Mod Creator REDEO AD EXORDIUM ( RAE )
    Progress: 95% internal final beta release - 85% official release
    RAE TWC-Wiki Eagle Standard interview ... RAE.net Homepage ... RAE TWZ-Germany
    Proudly Sega & Steam Boycotter since ETW! See why here or this petition
    Sorry for bad english here, there and in my tutorials > advanced horde invasion & hide/unhide stratmap-ui & Beginners modding



  11. #11
    gracul's Avatar 404 Not Found
    Artifex

    Join Date
    Dec 2007
    Location
    Poland
    Posts
    2,011

    Default Re: Miniscript to hide/unhide stratmap-ui whilst ingame

    Nice script!
    Anyway to assign it to F12?

    Code:
    declare_counter ui_hidden
    monitor_event ShortcutTriggered ShortcutTriggered object_manager hide_gui
      inc_counter ui_hidden 1
      if I_CompareCounter ui_hidden = 1
        hide_ui
        disable_movie_view
      end_if
      if I_CompareCounter ui_hidden = 2
        show_ui
        set_counter ui_hidden 0
      end_if
    end_monitor

  12. #12
    Userpro's Avatar =RAE= HostedMod Creator
    Join Date
    Jul 2008
    Location
    regno germanicum, teutonical forest
    Posts
    1,672

    Default Re: Miniscript to hide/unhide stratmap-ui whilst ingame

    Nice script!
    Anyway to assign it to F12?
    Thats impossible until you're able to remap the shortcut settings.
    Your script above looks okay, don't know if it works. You know that there will be always many little variations to script the same thing!
    Last edited by Userpro; November 11, 2009 at 02:12 PM.
    Visit our TWC M2TW-Kingdoms Hosted Mods Forum for...

    !!! RAE Development stopped --- read last Statement here !!!
    M2TW-Kingdoms Mod Creator REDEO AD EXORDIUM ( RAE )
    Progress: 95% internal final beta release - 85% official release
    RAE TWC-Wiki Eagle Standard interview ... RAE.net Homepage ... RAE TWZ-Germany
    Proudly Sega & Steam Boycotter since ETW! See why here or this petition
    Sorry for bad english here, there and in my tutorials > advanced horde invasion & hide/unhide stratmap-ui & Beginners modding



  13. #13
    gracul's Avatar 404 Not Found
    Artifex

    Join Date
    Dec 2007
    Location
    Poland
    Posts
    2,011

    Default Re: Miniscript to hide/unhide stratmap-ui whilst ingame

    It works and is probably the easiest way to script it.

  14. #14
    Userpro's Avatar =RAE= HostedMod Creator
    Join Date
    Jul 2008
    Location
    regno germanicum, teutonical forest
    Posts
    1,672

    Default Re: Miniscript to hide/unhide stratmap-ui whilst ingame

    If it really works then you've saved one "IF" cycle within one monitor-event. Its not a big profit, but it's still a profit.

    Edit:

    The imperceptible wait-state i've added to stay on the safe side for all mods in all situations, coz internal key-buffering depends on the different states, of the current mod-workload, when u are pressing the key!
    Last edited by Userpro; November 11, 2009 at 07:02 PM.
    Visit our TWC M2TW-Kingdoms Hosted Mods Forum for...

    !!! RAE Development stopped --- read last Statement here !!!
    M2TW-Kingdoms Mod Creator REDEO AD EXORDIUM ( RAE )
    Progress: 95% internal final beta release - 85% official release
    RAE TWC-Wiki Eagle Standard interview ... RAE.net Homepage ... RAE TWZ-Germany
    Proudly Sega & Steam Boycotter since ETW! See why here or this petition
    Sorry for bad english here, there and in my tutorials > advanced horde invasion & hide/unhide stratmap-ui & Beginners modding



  15. #15
    The Border Reiver's Avatar Artifex
    Patrician

    Join Date
    Feb 2006
    Location
    Australia
    Posts
    3,692

    Default Re: Miniscript to hide/unhide stratmap-ui whilst ingame

    Userpro, thankyou. I've updated my script accordingly.

  16. #16

  17. #17
    Gigantus's Avatar The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it
    Patrician Moderator Emeritus Administrator Emeritus Modding Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    46,896
    Blog Entries
    24

    Default Re: Miniscript to hide/unhide stratmap-ui whilst ingame

    By now I have included it in every mod I have worked on - really great stuff for screenshots. I am using it in conjunction with this tut of mine.



  18. #18
    Gigantus's Avatar The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it
    Patrician Moderator Emeritus Administrator Emeritus Modding Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    46,896
    Blog Entries
    24

    Default Re: Miniscript to hide/unhide stratmap-ui whilst ingame

    And now I have a keyboard that hasn't got a scroll lock button - that's a pain.

    I managed to find a small application called SharpKeys with which I have to assigned F12 as Scroll Lock button, trying to assign a key via the in game option just isn't flexible enough.

    Simply enter the button you want to use (make sure it isn't a button you normally use) in the From column and then select the Scroll Lock key in the To column. After that choose Write to Registry and restart your computer for the changes to take effect.


    Last edited by Gigantus; March 10, 2016 at 12:35 AM.



  19. #19
    Gigantus's Avatar The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it
    Patrician Moderator Emeritus Administrator Emeritus Modding Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    46,896
    Blog Entries
    24

    Default Re: Miniscript to hide/unhide stratmap-ui whilst ingame

    Just had a user complain that his save game got busted because he saved while the UI was disabled, couldn't re-enable it after reloading. Here now a recovery based on the original script:

    Code:
        ; --- Hide UI, press Scroll Lock, by UserPro ---
    
        declare_counter ui_showing
        monitor_event ShortcutTriggered ShortcutTriggered object_manager hide_gui
            wait 0.1
            if I_CompareCounter ui_showing = 0
                hide_ui
                disable_movie_view
                set_counter ui_showing 2         ; disabled state
            end_if
            if I_CompareCounter ui_showing = 1
                show_ui
                set_counter ui_showing 0         ; default state
            end_if
            if I_CompareCounter ui_showing = 2
                set_counter ui_showing 1         ; interim state
            end_if
        end_monitor
    
        ; --- Hide UI reset ---
    
        monitor_event GameReloaded TrueCondition
            if I_CompareCounter ui_showing = 2   ; disabled state
                set_counter ui_showing 0         ; default state
                show_ui                          ; enable UI
            end_if
            if I_CompareCounter ui_showing = 1   ; interim state
                set_counter ui_showing 0         ; default state
                show_ui                          ; enable UI
            end_if
        end_monitor
    Last edited by Gigantus; December 14, 2018 at 10:57 AM.



  20. #20
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,094

    Default Re: Miniscript to hide/unhide stratmap-ui whilst ingame

    GameReloaded saves the day again!

    The "interim/disabled" comments are back to front. A minor thing but some people trying to understand what it's doing might be confused by this.

    You could also do this to save a few lines and duplication...

    Code:
        monitor_event GameReloaded TrueCondition
            if not I_CompareCounter ui_showing = 0
                set_counter ui_showing 0         ; default state
                show_ui                          ; enable UI
            end_if
        end_monitor
    ...or...

    Code:
    if I_CompareCounter ui_showing != 0
    ~~~

    A word of caution for anybody wanting to use this in a script which has other show/hide UI behaviour in it: every time that other script shows or hides the UI it must also set this ui_showing counter accordingly, so this (thread's) script knows what the current state truly is.

    e.g. Another script that, for cinematic effect, hides the UI, does something, then re-shows the UI. If UI was hidden at the time that that other script happens then, after it, the UI will be visible again but ui_showing will still be saying that it's hidden. The next hit of the shortcut key won't do anything - it will need to be hit twice to hide the UI.

    Hmm, worse: your GameReloaded bit would fail to do its job, Gigantus. It would be safer to just remove the counter test from it...

    Code:
        monitor_event GameReloaded TrueCondition
            set_counter ui_showing 0         ; default state
            show_ui                          ; enable UI
        end_monitor
    ~~~

    Regarding the "F12 key" solution, it (and others) can be added into the game as a shortcut key without the need for 3rd party applications: http://www.twcenter.net/forums/showt...pting-purposes

Posting Permissions

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