Skip to content
This repository has been archived by the owner on Mar 31, 2024. It is now read-only.

Commit

Permalink
Update mod loader menu, close #76
Browse files Browse the repository at this point in the history
  • Loading branch information
gennariarmando committed Feb 19, 2022
1 parent 4fcfe87 commit 6c48136
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 31 deletions.
9 changes: 3 additions & 6 deletions resources/VHud/text/english.ini
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,9 @@ LANG_3 = Italian
LANG_4 = Spanish
FE_LANG = Language
FE_ML = Mod Loader
FE_ML1 = Enable Logging
FE_ML2 = Log Immediate Flush
FE_ML3 = Log Maximum Size
FE_ML4 = Refresh Modifications
FE_ML5 = Automatic Refresh
FE_ML6 = Modifications
FE_MODS = Modifications
FE_SELMOD = Selected Mod
FE_MLSET = Mod Settings
[GAMEPAD]
PAD_00 = Cycle Weapon Left
Expand Down
9 changes: 3 additions & 6 deletions resources/VHud/text/italian.ini
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,9 @@ LANG_3 = Italiano
LANG_4 = Spagnolo
FE_LANG = Lingua
FE_ML = Mod Loader
FE_ML1 = Enable Logging
FE_ML2 = Log Immediate Flush
FE_ML3 = Log Maximum Size
FE_ML4 = Refresh Modifications
FE_ML5 = Automatic Refresh
FE_ML6 = Modifications
FE_MODS = Modifiche
FE_SELMOD = Mod selezionata
FE_MLSET = Impostazioni Mod

[GAMEPAD]
PAD_00 = Cycle Weapon Left
Expand Down
103 changes: 88 additions & 15 deletions source/MenuNew.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,10 @@ void CMenuNew::BuildMenuScreen() {
if (auto modLoader = AddNewTab(settings, MENUENTRY_CHANGETAB, "FE_ML", NULL, false)) {

}

if (auto modLoaderModList = AddNewTab(settings, MENUENTRY_CHANGETAB, "FE_MODS", NULL, false)) {

}
}
}
}
Expand Down Expand Up @@ -567,6 +571,23 @@ void CMenuNew::BuildMenuScreen() {

}
}

// MENUSCREEN_LOADING
if (auto mod = AddNewScreen("BLANK")) {

}

// MENUSCREEN_MODLOADER_MOD_OPTION
if (VHud::bModLoader) {
char* mlText = TheText.Get("ML_F0HH");
if (mlText[0] != '\0') {
if (auto mod = AddNewScreen("FE_SELMOD")) {
if (auto modName = AddNewTab(mod, MENUENTRY_CHANGETAB, "FE_MLSET", NULL, false)) {

}
}
}
}
}

void CMenuNew::DrawBackground() {
Expand Down Expand Up @@ -779,6 +800,9 @@ void CMenuNew::SetInputTypeAndClear(int input, int n) {
//bShowMenu = true;
}

bPopulateOriginals = true;
fMenuEntryScrollOffset = 0.0f;

switch (input) {
case MENUINPUT_BAR:
nPreviousBarItem = nCurrentBarItem;
Expand Down Expand Up @@ -806,7 +830,6 @@ void CMenuNew::SetInputTypeAndClear(int input, int n) {
nCurrentEntryItem = n;
nCurrentEntryItemHover = MENU_HOVER_NONE;
nPreviousEntryItemHover = MENU_HOVER_NONE;
fMenuEntryScrollOffset = 0.0f;
break;
default:
break;
Expand Down Expand Up @@ -1212,6 +1235,7 @@ void CMenuNew::ProcessGoBack(int input) {

switch (nCurrentScreen) {
case MENUSCREEN_KEYBIND:
case MENUSCREEN_MODLOADER_MOD_OPTION:
if (int p = nPreviousScreen) {
nPreviousScreen = nCurrentScreen;
nCurrentScreen = p;
Expand Down Expand Up @@ -1267,8 +1291,9 @@ void CMenuNew::ProcessGoBack(int input) {
}
}

void CMenuNew::PopulateOriginalMenuStrings(int menupage) {
ProcessOriginalOptions(MENUPAGE_OPTIONS, 4, false, true);
void CMenuNew::PopulateOriginalMenuStrings(int prev, int i, int curr, int s, int e, int type) {
if (prev != -1 && i != -1)
ProcessOriginalOptions(prev, i, false, true);

OriginalMenuLoopCount = 0;

Expand All @@ -1277,19 +1302,19 @@ void CMenuNew::PopulateOriginalMenuStrings(int menupage) {
OriginalRightTextString[i][0] = '\0';
}

FrontEndMenuManager.SwitchToNewScreen(menupage);
FrontEndMenuManager.SwitchToNewScreen(curr);
FrontEndMenuManager.DrawStandardMenu(false);

BuildMenuEntriesFromOriginals();
BuildMenuEntriesFromOriginals(s, e, type);
}

void CMenuNew::BuildMenuEntriesFromOriginals() {
void CMenuNew::BuildMenuEntriesFromOriginals(int start, int end, int type) {
CMenuScreen* s = &MenuScreen[nCurrentScreen];
CMenuTab* t = &s->Tab[nCurrentTabItem];

for (int i = 0; i < OriginalMenuLoopCount - 1; i++) {
for (int i = start; i < end; i++) {
if (OriginalLeftTextString[i][0] != '\0') {
t->Entries[i].AddEntry(MENUENTRY_MODLOADER, "BLANK", 0, 0);
t->Entries[i].AddEntry(type, "BLANK", 0, 0);
}
else
t->Entries[i].RemoveEntry();
Expand Down Expand Up @@ -1432,12 +1457,22 @@ void CMenuNew::Process() {

if (!faststrcmp(MenuScreen[nCurrentScreen].Tab[nCurrentTabItem].tabName, "FE_ML")) {
if (bPopulateOriginals) {
PopulateOriginalMenuStrings(MENUPAGE_MODLOADER);
PopulateOriginalMenuStrings(MENUPAGE_OPTIONS, 4, MENUPAGE_MODLOADER, 0, 5, MENUENTRY_ORIGINAL);
bPopulateOriginals = false;
}
}
else if (!faststrcmp(MenuScreen[nCurrentScreen].Tab[nCurrentTabItem].tabName, "FE_MODS")) {
if (bPopulateOriginals) {
PopulateOriginalMenuStrings(MENUPAGE_MODLOADER, 5, MENUPAGE_MODLOADER_MODS, 0, 9, MENUENTRY_ORIGINAL);
bPopulateOriginals = false;
}
}
else if (!faststrcmp(MenuScreen[nCurrentScreen].Tab[nCurrentTabItem].tabName, "FE_MLSET")) {
if (bPopulateOriginals) {
PopulateOriginalMenuStrings(-1, -1, MENUPAGE_MODLOADER_SELECTED_MOD, 0, 2, MENUENTRY_ORIGINAL);
bPopulateOriginals = false;
}
}

tabItemBeforeScreenChange = nCurrentTabItem;

switch (nCurrentInputType) {
case MENUINPUT_BAR:
Expand Down Expand Up @@ -2308,8 +2343,41 @@ void CMenuNew::ProcessEntryStuff(int enter, int input) {
}
ApplyChanges();
break;
case MENUENTRY_MODLOADER:
ProcessOriginalOptions(MENUPAGE_MODLOADER, nCurrentEntryItem, input, enter);
case MENUENTRY_ORIGINAL:
{
bool process = false;
if (int page = MENUPAGE_EMPTY) {
if (!faststrcmp(MenuScreen[nCurrentScreen].Tab[nCurrentTabItem].tabName, "FE_ML")) {
process = true;
if (process) {
page = MENUPAGE_MODLOADER;
}
}
else if (!faststrcmp(MenuScreen[nCurrentScreen].Tab[nCurrentTabItem].tabName, "FE_MODS")) {
if (enter)
process = true;

if (process) {
page = MENUPAGE_MODLOADER_MODS;

nPreviousScreen = nCurrentScreen;
nCurrentScreen = MENUSCREEN_MODLOADER_MOD_OPTION;
bRequestScreenUpdate = true;
SetInputTypeAndClear(MENUINPUT_TAB);
}
}
else if (!faststrcmp(MenuScreen[nCurrentScreen].Tab[nCurrentTabItem].tabName, "FE_MLSET")) {
process = true;
if (process) {
page = MENUPAGE_MODLOADER_SELECTED_MOD;
strcpy(SavedOriginalLeftText, OriginalLeftTextString[nCurrentEntryItem]);
}
}

if (process)
ProcessOriginalOptions(page, nCurrentEntryItem, input, enter);
}
}
break;

// Sliders
Expand Down Expand Up @@ -3133,10 +3201,11 @@ void CMenuNew::DrawDefault() {
continue;

CFontNew::SetIgnoreGamePadSymbols(false);
CFontNew::SetClipX(SCREEN_WIDTH);

const int entryType = MenuScreen[nCurrentScreen].Tab[nCurrentTabItem].Entries[i].type;
switch (entryType) {
case MENUENTRY_MODLOADER:
case MENUENTRY_ORIGINAL:
leftText = OriginalLeftTextString[i];
break;
case MENUENTRY_LOADGAME:
Expand Down Expand Up @@ -3382,7 +3451,7 @@ void CMenuNew::DrawDefault() {
sprintf(rightTextTmp, "LANG_%d", TempSettings.language);
rightText = TextNew.GetText(rightTextTmp).text;
break;
case MENUENTRY_MODLOADER:
case MENUENTRY_ORIGINAL:
if (OriginalRightTextString[i][0]) {
rightText = OriginalRightTextString[i];
}
Expand Down Expand Up @@ -3422,6 +3491,10 @@ void CMenuNew::DrawDefault() {
shiftText = 0.0f;

if (rightText) {
if (nCurrentScreen == MENUSCREEN_MODLOADER_MOD_OPTION && i == 1) {
rightText[2] = '\0';
}

CFontNew::SetAlignment(CFontNew::ALIGN_RIGHT);
CFontNew::PrintString(menuEntry.left + menuEntry.right + SCREEN_COORD(-12.0f - shiftText), menuEntry.top + SCREEN_COORD(5.0f), rightText);

Expand Down
12 changes: 8 additions & 4 deletions source/MenuNew.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ typedef void (*funcCall)();

enum eOriginalMenuPages {
MENUPAGE_MODLOADER = 44,
MENUPAGE_MODLOADER_MODS = 45,
MENUPAGE_MODLOADER_SELECTED_MOD = 46,
NUM_ORIGINAL_MENUPAGES,
};

Expand Down Expand Up @@ -85,6 +87,7 @@ enum eMenuScreens {
MENUSCREEN_SAVE,
MENUSCREEN_KEYBIND,
MENUSCREEN_LOADING,
MENUSCREEN_MODLOADER_MOD_OPTION,
NUM_MENUSCREENS
};

Expand Down Expand Up @@ -148,7 +151,7 @@ enum eMenuEntries {
MENUENTRY_REDEFINEKEY,
MENUENTRY_KEYBINDING,
MENUENTRY_LANGUAGE,
MENUENTRY_MODLOADER,
MENUENTRY_ORIGINAL,
};

enum eMenuMessages {
Expand All @@ -165,7 +168,7 @@ enum eMenuMessages {

enum {
MAX_MENU_BAR_ITEMS = 12,
MAX_MENU_SCREENS = 12,
MAX_MENU_SCREENS = 16,
MAX_MENU_TABS = 128,
MAX_MENU_ENTRIES = 128,
MAX_HELP_TEXT = 8,
Expand Down Expand Up @@ -485,6 +488,7 @@ class CMenuNew {
int OriginalMenuLoopCount;
char OriginalLeftTextString[12][128];
char OriginalRightTextString[12][128];
char SavedOriginalLeftText[128];
bool bPopulateOriginals;

public:
Expand Down Expand Up @@ -531,8 +535,8 @@ class CMenuNew {
void ProcessGoDown(int input);
void ProcessGoThrough(int input);
void ProcessGoBack(int input);
void PopulateOriginalMenuStrings(int menupage);
void BuildMenuEntriesFromOriginals();
void PopulateOriginalMenuStrings(int prev, int i, int page, int s, int e, int type);
void BuildMenuEntriesFromOriginals(int start, int end, int type);
void Process();
void ScanGalleryPictures(bool force);
unsigned char FadeIn(unsigned char alpha);
Expand Down

0 comments on commit 6c48136

Please sign in to comment.