Skip to content

Commit

Permalink
Fixed OpenMCM bug and added ISMCMInitialized property
Browse files Browse the repository at this point in the history
  • Loading branch information
MrOctopus committed May 12, 2024
1 parent 2f3e023 commit f245f30
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 52 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ jobs:
path: ./repo

- name: Set up Python ${{ env.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ env.python-version }}
architecture: ${{ env.python-arch }}

- name: Pull papyrus compiler
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
repository: ${{ env.compiler-repo }}
token: ${{ env.compiler-token }}
Expand Down
17 changes: 7 additions & 10 deletions .github/workflows/wiki.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ on:
paths:
- 'main/source/**'
- 'wiki/**'

permissions:
contents: write
jobs:
deploy:
runs-on: ubuntu-latest
Expand All @@ -21,12 +22,12 @@ jobs:
path: ./nl_mcm

- name: Set up Python ${{ env.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ env.python-version }}

- name: PaPyDoc repo
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
repository: MrOctopus/PaPyDoc
path: ./PaPyDoc
Expand All @@ -36,10 +37,6 @@ jobs:

- name: Push wiki changes
if: success()
uses: Andrew-Chen-Wang/github-wiki-action@v3
env:
WIKI_DIR: ./nl_mcm/wiki/
GH_TOKEN: ${{ secrets.PRIVATE_TOKEN }}
GH_MAIL: ${{ secrets.NL_EMAIL }}
GH_NAME: ${{ github.repository_owner }}
WIKI_PUSH_MESSAGE: "Updated wiki"
uses: Andrew-Chen-Wang/github-wiki-action@v4
with:
path: ./nl_mcm/wiki/
8 changes: 7 additions & 1 deletion main/scripts/source/nl_mcm.psc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Scriptname nl_mcm extends SKI_ConfigBase
{!!!!!!DO NOT RECOMPILE!!!!!!
@author NeverLost
@version 1.1.2
@version 1.1.3
}

int function GetVersion()
Expand Down Expand Up @@ -103,6 +103,12 @@ float property SplashScreenY
endfunction
endproperty

bool property IsMCMInitialized hidden
bool function Get()
return Guard()
endfunction
endproperty

bool property PlayerUpdatedOptions auto hidden

int property QuickHotkey hidden
Expand Down
2 changes: 1 addition & 1 deletion main/scripts/source/nl_mcm_globalinfo.psc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Scriptname nl_mcm_globalinfo
{!!!!!!DO NOT RECOMPILE!!!!!!
@author NeverLost
@version 1.1.2
@version 1.1.3
}

bool function IsInstalled() global
Expand Down
8 changes: 7 additions & 1 deletion main/scripts/source/nl_mcm_module.psc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Scriptname nl_mcm_module extends Quest
{!!!!!!DO NOT RECOMPILE!!!!!!
@author NeverLost
@version 1.1.2
@version 1.1.3
}

; ------\-------\
Expand Down Expand Up @@ -377,6 +377,12 @@ nl_mcm property UNSAFE_RAW_MCM hidden
endfunction
endproperty

bool property IsMCMInitialized hidden
bool function Get()
return Guard()
endfunction
endproperty

bool property IsModuleRegistered hidden
bool function Get()
Guard()
Expand Down
2 changes: 1 addition & 1 deletion main/scripts/source/nl_mcm_playerloadalias.psc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Scriptname nl_mcm_playerloadalias extends ReferenceAlias
{!!!!!!DO NOT RECOMPILE!!!!!!
@author NeverLost
@version 1.1.2
@version 1.1.3
}

event OnInit()
Expand Down
60 changes: 28 additions & 32 deletions main/source/nl_mcm.psc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Scriptname nl_mcm extends SKI_ConfigBase
{
This documents the important functions in the backbone nl_mcm script.
@author NeverLost
@version 1.1.2
@version 1.1.3
}

int function GetVersion()
Expand Down Expand Up @@ -133,6 +133,12 @@ float property SplashScreenY
endfunction
endproperty

bool property IsMCMInitialized hidden
bool function Get()
return _initialized
endfunction
endproperty

bool property PlayerUpdatedOptions auto hidden

int property QuickHotkey hidden
Expand All @@ -144,17 +150,12 @@ int property QuickHotkey hidden
; Unregister
if keycode == -1
UnregisterForKey(_mcm_hotkey)
UnregisterForMenu(JOURNAL_MENU)
else
; Reregister
if _mcm_hotkey != -1
UnregisterForKey(_mcm_hotkey)
; Register
else
RegisterForMenu(JOURNAL_MENU)
endif

_journal_open = Ui.IsMenuOpen("Journal Menu")
RegisterForKey(keycode)
endif

Expand Down Expand Up @@ -182,6 +183,7 @@ string _key_store
string _common_store
string _common_store_owner
string _landing_page
string _landing_page_tmp
string _splash_path
string _persistent_preset

Expand Down Expand Up @@ -217,7 +219,13 @@ event OnGameReload()
; compacting it in the process. After the array has been compacted
; the array will be resized to equal the remaining active_modules

if !_initialized || _advanced_modules == 0
if !_initialized
return
endif

RegisterForMenu(JOURNAL_MENU)

if _advanced_modules == 0
return
endif

Expand Down Expand Up @@ -324,6 +332,7 @@ event OnUpdate()
_pages_z = Utility.ResizeIntArray(_pages_z, _buffered)

parent.OnGameReload()
RegisterForMenu(JOURNAL_MENU)

_buffered = 0
_initialized = True
Expand Down Expand Up @@ -963,15 +972,20 @@ event OnPageReset(string page)
endif
endif

if _landing_page != ""
; MIGHT return -1 because of a in-progress OpenMCM call
int i = Pages.Find(_landing_page)
string landing_page = _landing_page
if _landing_page_tmp != ""
landing_page = _landing_page_tmp
_landing_page_tmp = ""
endif

if landing_page != ""
; MIGHT return -1 because of a in-progress OpenMCM call
int i = Pages.Find(landing_page)
if i == -1
_landing_page = ""
landing_page = ""
endif

parent.SetPage(_landing_page, i)
parent.SetPage(landing_page, i)
elseif _splash_path != ""
LoadCustomContent(_splash_path, _splash_x, _splash_y)
endif
Expand Down Expand Up @@ -1349,28 +1363,9 @@ function OpenMCM(string landing_page_name = "")
return
endif

RegisterForMenu(JOURNAL_MENU)

string old_landing_page = _landing_page
_landing_page = landing_page_name

_quick_open = true
_landing_page_tmp = landing_page_name
Input.TapKey(Input.GetMappedKey("Journal"))

string flash_path = MENU_ROOT + ".contentHolder.modListPanel.decorTitle.textHolder.textField.text"
int i = 0

; Not a true spinlock because users might muck this up
while i < 5 || Ui.GetString(JOURNAL_MENU, flash_path) != ModName
Utility.WaitMenuMode(SPINLOCK_TIMER)
i += 1
endwhile

_landing_page = old_landing_page

if _mcm_hotkey == -1
UnregisterForMenu(JOURNAL_MENU)
endif
endfunction

function CloseMCM(bool close_journal = false)
Expand All @@ -1381,6 +1376,7 @@ function CloseMCM(bool close_journal = false)
; Lock
_ctd_lock = true

; This also checks if the menu is open
if Ui.GetString(JOURNAL_MENU, MENU_ROOT + ".contentHolder.modListPanel.decorTitle.textHolder.textField.text") != ModName
_ctd_lock = false
return
Expand Down
4 changes: 2 additions & 2 deletions main/source/nl_mcm_globalinfo.psc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Scriptname nl_mcm_globalinfo
{
This documents useful global functions to check the nl_mcm api version/state.
@author NeverLost
@version 1.1.2
@version 1.1.3
}

bool function IsInstalled() global
Expand All @@ -18,5 +18,5 @@ int function CurrentVersion() global
Get the current version of nl_mcm
@return The current nl_mcm version
}
return 112
return 113
endfunction
12 changes: 11 additions & 1 deletion main/source/nl_mcm_module.psc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Scriptname nl_mcm_module extends Quest
For the original mcm Api, see [link](https://github.com/schlangster/skyui/wiki/MCM-API-Reference). \
Only STATE api functions are supported as part of the new api.
@author NeverLost
@version 1.1.2
@version 1.1.3
}

; ------\-------\
Expand Down Expand Up @@ -644,6 +644,16 @@ nl_mcm property UNSAFE_RAW_MCM hidden
endfunction
endproperty

bool property IsMCMInitialized hidden
{
Check if the mcm has actually finished initializing.
@get Get the initialized status of the mcm
}
bool function Get()
return _MCM.IsMCMInitialized
endfunction
endproperty

bool property IsModuleRegistered hidden
{
Check if the module is registered to a mcm.
Expand Down
2 changes: 1 addition & 1 deletion main/source/nl_mcm_playerloadalias.psc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Scriptname nl_mcm_playerloadalias extends ReferenceAlias
{
@author NeverLost
@version 1.1.2
@version 1.1.3
}

quest _owner
Expand Down
13 changes: 13 additions & 0 deletions wiki/2. Quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,19 @@ Notably the following events have also had their name/parameters changed:

## Common Issues

### The OnUpdate is triggering twice in one my mcm quest scripts
NL_MCM registers for a single OnUpdate event to signal that it has finished initializing. To ignore this event either move your OnUpdate event to another quest, or check for the mcm initialization status in your nl_mcm_module script's OnUpdate event:

```papyrus
Scriptname myModMCM extends nl_mcm_module
event OnUpdate()
if IsMCMInitialized
; DO STUFF HERE
endif
endevent
```

### I can't find nl_mcm_module

This means you haven't installed the NL_MCM SDK correctly. This SDK needs to be accessible to the Creation Kit for the scripts to show up. If you're launching the CK via MO2, make sure the SDK is installed like a regular mod and is enabled in the left panel. (It won't show in the right panel, because it doesn't have an ESP.)
Expand Down

0 comments on commit f245f30

Please sign in to comment.