Allow song specific choices such as modules, skins and sfx.

Set in playerdata.ini, modules.ini, skins.ini and sfx.ini respectively.
This commit is contained in:
Jay39w
2019-11-12 23:53:26 +00:00
parent 7a119900e2
commit 5416c60f9a
4 changed files with 153 additions and 30 deletions
@@ -32,6 +32,8 @@ namespace TLAC::Components
int ActionVol;
int ActionSlideVol;
int UsePVEquip;
int UsePVSFXEquip;
int UsePVSkinEquip;
bool ShowGreatClearBorder;
bool ShowExcellentClearBorder;
bool ShowRivalClearBorder;
@@ -249,13 +249,6 @@ namespace TLAC::Components
customPlayerData->SlideSeEquip = config.GetIntegerValue("slide_se_equip");
customPlayerData->ChainslideSeEquip = config.GetIntegerValue("chainslide_se_equip");
customPlayerData->SlidertouchSeEquip = config.GetIntegerValue("slidertouch_se_equip");
//customPlayerData->ModuleEquip0 = config.GetIntegerValue("module_equip0"); See below for explanation
//customPlayerData->ModuleEquip1 = config.GetIntegerValue("module_equip1");
//customPlayerData->ModuleEquip2 = config.GetIntegerValue("module_equip2");
//customPlayerData->ModuleEquip3 = config.GetIntegerValue("module_equip3");
//customPlayerData->ModuleEquip4 = config.GetIntegerValue("module_equip4");
//customPlayerData->ModuleEquip5 = config.GetIntegerValue("module_equip5");
customPlayerData->UsePVEquip = config.GetIntegerValue("use_pv_module_equip");
customPlayerData->ModuleEquipCmn0 = config.GetIntegerValue("module_equip_cmn0");
customPlayerData->ModuleEquipCmn1 = config.GetIntegerValue("module_equip_cmn1");
customPlayerData->ModuleEquipCmn2 = config.GetIntegerValue("module_equip_cmn2");
@@ -264,7 +257,9 @@ namespace TLAC::Components
customPlayerData->ModuleEquipCmn5 = config.GetIntegerValue("module_equip_cmn5");
customPlayerData->ActionVol = config.GetIntegerValue("act_vol");
customPlayerData->ActionSlideVol = config.GetIntegerValue("act_slide_vol");
customheaditemequip = config.GetIntegerValue("head_item");
customPlayerData->UsePVSFXEquip = config.GetBooleanValue("use_pv_sfx_equip");
customPlayerData->UsePVSkinEquip = config.GetBooleanValue("use_pv_skin_equip");
customPlayerData->UsePVEquip = config.GetBooleanValue("use_pv_module_equip");
customPlayerData->ShowExcellentClearBorder = config.GetBooleanValue("border_excellent");
customPlayerData->ShowGreatClearBorder = config.GetBooleanValue("border_great");
customPlayerData->ShowRivalClearBorder = config.GetBooleanValue("border_rival");
@@ -289,9 +284,13 @@ namespace TLAC::Components
setIfNotEqual(&playerData->module_equip_cmn3, customPlayerData->ModuleEquipCmn3, 0);
setIfNotEqual(&playerData->module_equip_cmn4, customPlayerData->ModuleEquipCmn4, 0);
setIfNotEqual(&playerData->module_equip_cmn5, customPlayerData->ModuleEquipCmn5, 0);
setIfNotEqual(headitemequip, customheaditemequip, 0);
setIfNotEqual(&playerData->act_vol, customPlayerData->ActionVol, 100);
setIfNotEqual(&playerData->act_slide_vol, customPlayerData->ActionSlideVol, 100);
setIfNotEqual(&playerData->btn_se_equip, customPlayerData->BtnSeEquip, -1);
setIfNotEqual(&playerData->slide_se_equip, customPlayerData->SlideSeEquip, -1);
setIfNotEqual(&playerData->chainslide_se_equip, customPlayerData->ChainslideSeEquip, -1);
setIfNotEqual(&playerData->slidertouch_se_equip, customPlayerData->SlidertouchSeEquip, -1);
setIfNotEqual(&playerData->act_toggle, customPlayerData->ActionSE, 1);
std::string* mylistString;
std::vector<std::string> mylistStringVec;
@@ -457,33 +456,26 @@ namespace TLAC::Components
swprintf(val, 32, L"%d", playerData->act_slide_vol);
WritePrivateProfileStringW(L"playerdata", L"act_slide_vol", val, configPath);
}
if (playerData->use_pv_module_equip != 1)
if (customPlayerData->UsePVEquip != playerData->use_pv_module_equip)
{
playerData->use_pv_module_equip = 1;
}
if (customheaditemequip != *headitemequip)
if (customPlayerData->UsePVSFXEquip != playerData->use_pv_btn_se_equip)
{
customheaditemequip = *headitemequip;
WCHAR val[32];
swprintf(val, 32, L"%d", *headitemequip);
WritePrivateProfileStringW(L"playerdata", L"head_item", val, configPath);
playerData->use_pv_btn_se_equip = 1;
playerData->use_pv_chainslide_se_equip = 1;
playerData->use_pv_slidertouch_se_equip = 1;
playerData->use_pv_slide_se_equip = 1;
}
if (customPlayerData->UsePVSkinEquip != playerData->use_pv_skin_equip)
{
playerData->use_pv_skin_equip = 1;
}
setIfNotEqual(&playerData->level, customPlayerData->LevelNum, 1);
setIfNotEqual(&playerData->level_plate_id, customPlayerData->LevelPlateId, 0);
setIfNotEqual(&playerData->level_plate_effect, customPlayerData->LevelPlateEffect, 0);
setIfNotEqual(&playerData->btn_se_equip, customPlayerData->BtnSeEquip, -1);
setIfNotEqual(&playerData->slide_se_equip, customPlayerData->SlideSeEquip, -1);
setIfNotEqual(&playerData->chainslide_se_equip, customPlayerData->ChainslideSeEquip, -1);
setIfNotEqual(&playerData->slidertouch_se_equip, customPlayerData->SlidertouchSeEquip, -1);
setIfNotEqual(&playerData->act_toggle, customPlayerData->ActionSE, 1);
//setIfNotEqual(&playerData->module_equip0, customPlayerData->ModuleEquip0, 0); Do NOT recommend using this
//setIfNotEqual(&playerData->module_equip1, customPlayerData->ModuleEquip1, 0);
//setIfNotEqual(&playerData->module_equip2, customPlayerData->ModuleEquip2, 0);
//setIfNotEqual(&playerData->module_equip3, customPlayerData->ModuleEquip3, 0);
//setIfNotEqual(&playerData->module_equip4, customPlayerData->ModuleEquip4, 0);
//setIfNotEqual(&playerData->module_equip5, customPlayerData->ModuleEquip5, 0);
// Display clear borders on the progress bar
playerData->clear_border = (customPlayerData->ShowRivalClearBorder << 2) | (customPlayerData->ShowExcellentClearBorder << 1) | (customPlayerData->ShowGreatClearBorder);
@@ -14,14 +14,21 @@ namespace TLAC::Components
WCHAR ScoreSaver::configPath[256];
WCHAR ScoreSaver::rival_configPath[256];
WCHAR ScoreSaver::modules_configPath[256];
WCHAR ScoreSaver::skins_configPath[256];
WCHAR ScoreSaver::sfx_configPath[256];
ScoreSaver::ScoreSaver()
{
std::string utf8path = TLAC::framework::GetModuleDirectory() + "/scores.ini";
MultiByteToWideChar(CP_UTF8, 0, utf8path.c_str(), -1, configPath, 256);
utf8path = TLAC::framework::GetModuleDirectory() + "/rivalscores.ini";
MultiByteToWideChar(CP_UTF8, 0, utf8path.c_str(), -1, rival_configPath, 256);
utf8path = TLAC::framework::GetModuleDirectory() + "/modules.ini";
utf8path = TLAC::framework::GetModuleDirectory() + "/pv_equip/modules.ini";
MultiByteToWideChar(CP_UTF8, 0, utf8path.c_str(), -1, modules_configPath, 256);
utf8path = TLAC::framework::GetModuleDirectory() + "/pv_equip/skins.ini";
MultiByteToWideChar(CP_UTF8, 0, utf8path.c_str(), -1, skins_configPath, 256);
utf8path = TLAC::framework::GetModuleDirectory() + "/pv_equip/sfx.ini";
MultiByteToWideChar(CP_UTF8, 0, utf8path.c_str(), -1, sfx_configPath, 256);
}
ScoreSaver::~ScoreSaver()
@@ -559,6 +566,21 @@ namespace TLAC::Components
const WCHAR section[] = L"modules";
swprintf(keyBase, 32, L"pv.%03d", pvNum);
swprintf(key, 32, L"%ls.skin", keyBase);
int INISkin = GetPrivateProfileIntW(section, key, 0, skins_configPath);
if (INISkin > 0)
{
DivaScore* cachedScore = GetCachedScore(pvNum, diff, exDiff);
if (cachedScore == nullptr)
{
ScoreCache[diff].push_back(DivaScore(pvNum, exDiff));
cachedScore = GetCachedScore(pvNum, diff, exDiff);
}
if (cachedScore != nullptr)
{
cachedScore->per_skin_equip = INISkin;
}
}
for (int i = 0; i < 6; ++i)
{
@@ -576,9 +598,6 @@ namespace TLAC::Components
if (cachedScore != nullptr)
{
cachedScore->per_module_equip[i] = INImodule;
WCHAR val[32];
swprintf(val, 32, L"%d", INImodule);
WritePrivateProfileStringW(L"modules", key, val, modules_configPath);
}
}
}
@@ -615,6 +634,110 @@ namespace TLAC::Components
}
void ScoreSaver::UpdateSingleScoreCacheSkinsEntry(int pvNum, int diff, int exDiff)
{
if (pvNum < 0 || diff < 0 || exDiff < 0 || pvNum > 999 || diff > 3 || exDiff > 1)
return;
WCHAR keyBase[32]; // needs to be big enough to store pv.999
WCHAR key[32]; // needs to be big enough to store pv.999.module5
const WCHAR section[] = L"skins";
swprintf(keyBase, 32, L"pv.%03d", pvNum);
swprintf(key, 32, L"%ls.skin", keyBase);
int INISkin = GetPrivateProfileIntW(section, key, 0, skins_configPath);
if (INISkin > 0)
{
DivaScore* cachedScore = GetCachedScore(pvNum, diff, exDiff);
if (cachedScore == nullptr)
{
ScoreCache[diff].push_back(DivaScore(pvNum, exDiff));
cachedScore = GetCachedScore(pvNum, diff, exDiff);
}
if (cachedScore != nullptr)
{
cachedScore->per_skin_equip = INISkin;
}
}
}
void ScoreSaver::UpdateSingleScoreCacheSFXEntry(int pvNum, int diff, int exDiff)
{
if (pvNum < 0 || diff < 0 || exDiff < 0 || pvNum > 999 || diff > 3 || exDiff > 1)
return;
WCHAR keyBase[32]; // needs to be big enough to store pv.999
WCHAR key[32]; // needs to be big enough to store pv.999.module5
const WCHAR section[] = L"SFX";
swprintf(keyBase, 32, L"pv.%03d", pvNum);
swprintf(key, 32, L"%ls.btn", keyBase);
int INIBtn = GetPrivateProfileIntW(section, key, 0, sfx_configPath);
if (INIBtn > 0)
{
DivaScore* cachedScore = GetCachedScore(pvNum, diff, exDiff);
if (cachedScore == nullptr)
{
ScoreCache[diff].push_back(DivaScore(pvNum, exDiff));
cachedScore = GetCachedScore(pvNum, diff, exDiff);
}
if (cachedScore != nullptr)
{
cachedScore->per_btn_se_equip = INIBtn;
}
}
swprintf(keyBase, 32, L"pv.%03d", pvNum);
swprintf(key, 32, L"%ls.chain", keyBase);
int INIChain = GetPrivateProfileIntW(section, key, 0, sfx_configPath);
if (INIChain > 0)
{
DivaScore* cachedScore = GetCachedScore(pvNum, diff, exDiff);
if (cachedScore == nullptr)
{
ScoreCache[diff].push_back(DivaScore(pvNum, exDiff));
cachedScore = GetCachedScore(pvNum, diff, exDiff);
}
if (cachedScore != nullptr)
{
cachedScore->per_chainslide_se_equip = INIChain;
}
}
swprintf(keyBase, 32, L"pv.%03d", pvNum);
swprintf(key, 32, L"%ls.slide", keyBase);
int INISlide = GetPrivateProfileIntW(section, key, 0, sfx_configPath);
if (INISlide > 0)
{
DivaScore* cachedScore = GetCachedScore(pvNum, diff, exDiff);
if (cachedScore == nullptr)
{
ScoreCache[diff].push_back(DivaScore(pvNum, exDiff));
cachedScore = GetCachedScore(pvNum, diff, exDiff);
}
if (cachedScore != nullptr)
{
cachedScore->per_slide_se_equip = INISlide;
}
}
swprintf(keyBase, 32, L"pv.%03d", pvNum);
swprintf(key, 32, L"%ls.touch", keyBase);
int INITouch = GetPrivateProfileIntW(section, key, 0, sfx_configPath);
if (INITouch > 0)
{
DivaScore* cachedScore = GetCachedScore(pvNum, diff, exDiff);
if (cachedScore == nullptr)
{
ScoreCache[diff].push_back(DivaScore(pvNum, exDiff));
cachedScore = GetCachedScore(pvNum, diff, exDiff);
}
if (cachedScore != nullptr)
{
cachedScore->per_slidertouch_se_equip = INITouch;
}
}
}
void ScoreSaver::FixScoreCacheAddresses(int diff)
{
// update score begin and end vars from game
@@ -633,6 +756,8 @@ namespace TLAC::Components
UpdateSingleScoreCacheEntry(pvNum, diff, exDiff, false);
UpdateSingleScoreCacheRivalEntry(pvNum, diff, exDiff);
UpdateSingleScoreCacheModulesEntry(pvNum, diff, exDiff);
UpdateSingleScoreCacheSkinsEntry(pvNum, diff, exDiff);
UpdateSingleScoreCacheSFXEntry(pvNum, diff, exDiff);
}
}
}
@@ -111,6 +111,8 @@ namespace TLAC::Components
static void UpdateSingleScoreCacheEntry(int pvNum, int diff, int exDiff, bool doDefaultsReset);
static void UpdateSingleScoreCacheRivalEntry(int pvNum, int diff, int exDiff);
static void UpdateSingleScoreCacheModulesEntry(int pvNum, int diff, int exDiff);
static void UpdateSingleScoreCacheSkinsEntry(int pvNum, int diff, int exDiff);
static void UpdateSingleScoreCacheSFXEntry(int pvNum, int diff, int exDiff);
static void FixScoreCacheAddresses(int diff); // only call this from the main thread
static DivaScore* GetCachedScore(int pvNum, int diff, int exDiff);
static void UpdateClearCounts();
@@ -127,6 +129,8 @@ namespace TLAC::Components
static WCHAR configPath[256];
static WCHAR rival_configPath[256];
static WCHAR modules_configPath[256];
static WCHAR skins_configPath[256];
static WCHAR sfx_configPath[256];
static std::thread initThread;
int currentPv;