actually save shit

This commit is contained in:
StapleButter 2018-12-14 04:25:39 +01:00
parent fd54abd900
commit 5efb162302
3 changed files with 42 additions and 16 deletions

View File

@ -54,6 +54,10 @@ int SocketBindAnyAddr;
int SavestateRelocSRAM;
int AudioVolume;
int MicInputType;
char MicWavPath[512];
typedef struct
{
char Name[16];
@ -61,7 +65,7 @@ typedef struct
void* Value;
int DefaultInt;
char* DefaultStr;
int StrLength;
int StrLength; // should be set to actual array length minus one
} ConfigEntry;
@ -116,6 +120,10 @@ ConfigEntry ConfigFile[] =
{"SavStaRelocSRAM", 0, &SavestateRelocSRAM, 1, NULL, 0},
{"AudioVolume", 0, &AudioVolume, 255, NULL, 0},
{"MicInputType", 0, &MicInputType, 1, NULL, 0},
{"MicWavPath", 1, MicWavPath, 0, "", 511},
{"", -1, NULL, 0, NULL, 0}
};
@ -130,7 +138,10 @@ void Load()
if (entry->Type == 0)
*(int*)entry->Value = entry->DefaultInt;
else
{
strncpy((char*)entry->Value, entry->DefaultStr, entry->StrLength);
((char*)entry->Value)[entry->StrLength] = '\0';
}
entry++;
}

View File

@ -59,6 +59,10 @@ extern int SocketBindAnyAddr;
extern int SavestateRelocSRAM;
extern int AudioVolume;
extern int MicInputType;
extern char MicWavPath[512];
}
#endif // CONFIG_H

View File

@ -18,6 +18,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "libui/ui.h"
@ -33,7 +34,9 @@ namespace DlgAudioSettings
bool opened;
uiWindow* win;
//
uiSlider* slVolume;
uiRadioButtons* rbMicInputType;
uiEntry* txMicWavPath;
int OnCloseWindow(uiWindow* window, void* blarg)
@ -50,9 +53,12 @@ void OnCancel(uiButton* btn, void* blarg)
void OnOk(uiButton* btn, void* blarg)
{
/*Config::DirectBoot = uiCheckboxChecked(cbDirectBoot);
Config::Threaded3D = uiCheckboxChecked(cbThreaded3D);
Config::SocketBindAnyAddr = uiCheckboxChecked(cbBindAnyAddr);*/
Config::AudioVolume = uiSliderValue(slVolume);
Config::MicInputType = uiRadioButtonsSelected(rbMicInputType);
char* wavpath = uiEntryText(txMicWavPath);
strncpy(Config::MicWavPath, wavpath, 511);
uiFreeText(wavpath);
Config::Save();
@ -88,8 +94,8 @@ void Open()
uiLabel* label_vol = uiNewLabel("Volume:");
uiBoxAppend(in_ctrl, uiControl(label_vol), 0);
uiSlider* volslider = uiNewSlider(0, 255);
uiBoxAppend(in_ctrl, uiControl(volslider), 0);
slVolume = uiNewSlider(0, 255);
uiBoxAppend(in_ctrl, uiControl(slVolume), 0);
}
{
@ -100,18 +106,18 @@ void Open()
uiBox* in_ctrl = uiNewVerticalBox();
uiGroupSetChild(grp, uiControl(in_ctrl));
uiRadioButtons* mictypes = uiNewRadioButtons();
uiRadioButtonsAppend(mictypes, "None");
uiRadioButtonsAppend(mictypes, "Microphone");
uiRadioButtonsAppend(mictypes, "White noise");
uiRadioButtonsAppend(mictypes, "WAV file:");
uiBoxAppend(in_ctrl, uiControl(mictypes), 0);
rbMicInputType = uiNewRadioButtons();
uiRadioButtonsAppend(rbMicInputType, "None");
uiRadioButtonsAppend(rbMicInputType, "Microphone");
uiRadioButtonsAppend(rbMicInputType, "White noise");
uiRadioButtonsAppend(rbMicInputType, "WAV file:");
uiBoxAppend(in_ctrl, uiControl(rbMicInputType), 0);
uiBox* path_box = uiNewHorizontalBox();
uiBoxAppend(in_ctrl, uiControl(path_box), 0);
uiEntry* path_entry = uiNewEntry();
uiBoxAppend(path_box, uiControl(path_entry), 1);
txMicWavPath = uiNewEntry();
uiBoxAppend(path_box, uiControl(txMicWavPath), 1);
uiButton* path_browse = uiNewButton("...");
uiBoxAppend(path_box, uiControl(path_browse), 0);
@ -134,7 +140,12 @@ void Open()
uiBoxAppend(in_ctrl, uiControl(btnok), 0);
}
// shit
if (Config::AudioVolume < 0) Config::AudioVolume = 0;
else if (Config::AudioVolume > 255) Config::AudioVolume = 255;
uiSliderSetValue(slVolume, Config::AudioVolume);
uiRadioButtonsSetSelected(rbMicInputType, Config::MicInputType);
uiEntrySetText(txMicWavPath, Config::MicWavPath);
uiControlShow(uiControl(win));
}