mirror of https://github.com/stella-emu/stella.git
started converting high score definitions saving to JSON
This commit is contained in:
parent
5c21fb3e4b
commit
efb94f1b5f
|
@ -48,13 +48,16 @@
|
|||
#include "Cart.hxx"
|
||||
#include "Console.hxx"
|
||||
#include "Launcher.hxx"
|
||||
|
||||
#include "json.hxx"
|
||||
#include "Base.hxx"
|
||||
|
||||
#include "HighScoresManager.hxx"
|
||||
|
||||
using namespace BSPF;
|
||||
using namespace std;
|
||||
using namespace HSM;
|
||||
using Common::Base;
|
||||
using json = nlohmann::json;
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
HighScoresManager::HighScoresManager(OSystem& osystem)
|
||||
|
@ -91,38 +94,42 @@ Properties& HighScoresManager::properties(Properties& props) const
|
|||
return props;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string HighScoresManager::getPropIdx(const Properties& props, PropType type, uInt32 idx) const
|
||||
{
|
||||
string property = props.get(type);
|
||||
|
||||
replace(property.begin(), property.end(), ',', ' ');
|
||||
replace(property.begin(), property.end(), '|', ' ');
|
||||
istringstream buf(property);
|
||||
string result;
|
||||
|
||||
for (uInt32 i = 0; i <= idx; ++i)
|
||||
if(!(buf >> result))
|
||||
return "";
|
||||
|
||||
return result;
|
||||
}
|
||||
//// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
//string HighScoresManager::getPropIdx(const Properties& props, PropType type, uInt32 idx) const
|
||||
//{
|
||||
// string property = props.get(type);
|
||||
//
|
||||
// replace(property.begin(), property.end(), ',', ' ');
|
||||
// replace(property.begin(), property.end(), '|', ' ');
|
||||
// istringstream buf(property);
|
||||
// string result;
|
||||
//
|
||||
// for (uInt32 i = 0; i <= idx; ++i)
|
||||
// if(!(buf >> result))
|
||||
// return "";
|
||||
//
|
||||
// return result;
|
||||
//}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool HighScoresManager::enabled() const
|
||||
{
|
||||
Properties props;
|
||||
|
||||
return (!getPropIdx(properties(props), PropType::Cart_Addresses, 0).empty());
|
||||
return !getPropStr(properties(props), SCORE_ADDRESS_0).empty();
|
||||
|
||||
//return (!getPropIdx(properties(props), PropType::Cart_Addresses, 0).empty());
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt32 HighScoresManager::numVariations(const Properties& props) const
|
||||
{
|
||||
string numVariations = getPropIdx(props, PropType::Cart_Variations);
|
||||
uInt32 maxVariations = MAX_VARIATIONS;
|
||||
return min(getPropInt(props, VARIATIONS_COUNT, DEFAULT_VARIATION), MAX_VARIATIONS);
|
||||
|
||||
return min(uInt32(stringToInt(numVariations, DEFAULT_VARIATION)), maxVariations);
|
||||
//string numVariations = getPropIdx(props, PropType::Cart_Variations);
|
||||
//uInt32 maxVariations = MAX_VARIATIONS;
|
||||
|
||||
//return min(uInt32(stringToInt(numVariations, DEFAULT_VARIATION)), maxVariations);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -146,23 +153,86 @@ bool HighScoresManager::get(const Properties& props, uInt32& numVariationsR,
|
|||
info.varsAddr = varAddress(props);
|
||||
info.specialAddr = specialAddress(props);
|
||||
|
||||
for (uInt32 a = 0; a < numAddrBytes(props); ++a)
|
||||
{
|
||||
string addr = getPropIdx(props, PropType::Cart_Addresses, a);
|
||||
int num = numAddrBytes(props);
|
||||
if(num >= 1)
|
||||
info.scoreAddr[0] = getPropAddr(props, SCORE_ADDRESS_0);
|
||||
if(num >= 2)
|
||||
info.scoreAddr[1] = getPropAddr(props, SCORE_ADDRESS_1);
|
||||
if(num >= 3)
|
||||
info.scoreAddr[2] = getPropAddr(props, SCORE_ADDRESS_2);
|
||||
if(num >= 4)
|
||||
info.scoreAddr[3] = getPropAddr(props, SCORE_ADDRESS_3);
|
||||
|
||||
info.scoreAddr[a] = stringToIntBase16(addr);
|
||||
}
|
||||
return !getPropStr(props, SCORE_ADDRESS_0).empty();
|
||||
|
||||
return (!getPropIdx(props, PropType::Cart_Addresses, 0).empty());
|
||||
//for (uInt32 a = 0; a < numAddrBytes(props); ++a)
|
||||
//{
|
||||
|
||||
|
||||
|
||||
// string addr = getPropIdx(props, PropType::Cart_Addresses, a);
|
||||
|
||||
// info.scoreAddr[a] = stringToIntBase16(addr);
|
||||
//}
|
||||
|
||||
//return (!getPropIdx(props, PropType::Cart_Addresses, 0).empty());
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void HighScoresManager::set(Properties& props, uInt32 numVariations,
|
||||
const ScoresInfo& info) const
|
||||
{
|
||||
uInt32 maxVariations = MAX_VARIATIONS;
|
||||
json hsProp = json::object();
|
||||
|
||||
// handle variations
|
||||
hsProp[VARIATIONS_COUNT] = min(numVariations, maxVariations);
|
||||
if(numVariations != DEFAULT_VARIATION)
|
||||
hsProp[VARIATIONS_ADDRESS] = "0x" + Base::toString(info.varsAddr, Base::Fmt::_16);
|
||||
if(info.varsBCD != DEFAULT_VARS_BCD)
|
||||
hsProp[VARIATIONS_BCD] = info.varsBCD;
|
||||
if(info.varsZeroBased != DEFAULT_VARS_ZERO_BASED)
|
||||
hsProp[VARIATIONS_ZERO_BASED] = info.varsZeroBased;
|
||||
|
||||
// handle score
|
||||
if(info.numDigits != DEFAULT_DIGITS)
|
||||
hsProp[SCORE_DIGITS] = info.numDigits;
|
||||
if(info.trailingZeroes != DEFAULT_TRAILING)
|
||||
hsProp[SCORE_TRAILING_ZEROES] = info.trailingZeroes;
|
||||
if(info.scoreBCD != DEFAULT_SCORE_BCD)
|
||||
hsProp[SCORE_BCD] = info.scoreBCD;
|
||||
if(info.scoreInvert != DEFAULT_SCORE_REVERSED)
|
||||
hsProp[SCORE_INVERTED] = info.scoreInvert;
|
||||
uInt32 addrBytes = numAddrBytes(info.numDigits, info.trailingZeroes);
|
||||
|
||||
json addresses = json::array();
|
||||
for(uInt32 a = 0; a < addrBytes; ++a)
|
||||
addresses.push_back("0x" + Base::toString(info.scoreAddr[a], Base::Fmt::_16));
|
||||
hsProp[SCORE_ADDRESSES] = addresses;
|
||||
|
||||
// handle special
|
||||
if(!info.special.empty())
|
||||
hsProp[SPECIAL_LABEL] = info.special;
|
||||
if(!info.special.empty())
|
||||
hsProp[SPECIAL_ADDRESS] = "0x" + Base::toString(info.specialAddr, Base::Fmt::_16);
|
||||
if(info.specialBCD != DEFAULT_SPECIAL_BCD)
|
||||
hsProp[SPECIAL_BCD] = info.specialBCD;
|
||||
if(info.specialZeroBased != DEFAULT_SPECIAL_ZERO_BASED)
|
||||
hsProp[SPECIAL_ZERO_BASED] = info.specialZeroBased;
|
||||
|
||||
// handle notes
|
||||
if(!info.notes.empty())
|
||||
hsProp[NOTES] = info.notes;
|
||||
|
||||
//if(info.armRAM != DEFAULT_ARM_RAM)
|
||||
// hsProp[""] = info.armRAM ? "1" : "0"; // TODO add ',' to numDigits!
|
||||
|
||||
props.set(PropType::Cart_Highscore, hsProp.dump());
|
||||
|
||||
|
||||
|
||||
ostringstream buf;
|
||||
string output;
|
||||
uInt32 maxVariations = MAX_VARIATIONS;
|
||||
|
||||
props.set(PropType::Cart_Variations, to_string(min(numVariations, maxVariations)));
|
||||
|
||||
|
@ -212,78 +282,98 @@ void HighScoresManager::set(Properties& props, uInt32 numVariations,
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt32 HighScoresManager::numDigits(const Properties& props) const
|
||||
{
|
||||
string digits = getPropIdx(props, PropType::Cart_Formats, IDX_SCORE_DIGITS);
|
||||
uInt32 maxScoreDigits = MAX_SCORE_DIGITS;
|
||||
return min(getPropInt(props, SCORE_DIGITS, DEFAULT_DIGITS), MAX_SCORE_DIGITS);
|
||||
|
||||
return min(uInt32(stringToInt(digits, DEFAULT_DIGITS)), maxScoreDigits);
|
||||
//string digits = getPropIdx(props, PropType::Cart_Formats, IDX_SCORE_DIGITS);
|
||||
//uInt32 maxScoreDigits = MAX_SCORE_DIGITS;
|
||||
|
||||
//return min(uInt32(stringToInt(digits, DEFAULT_DIGITS)), maxScoreDigits);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt32 HighScoresManager::trailingZeroes(const Properties& props) const
|
||||
{
|
||||
string trailing = getPropIdx(props, PropType::Cart_Formats, IDX_TRAILING_ZEROES);
|
||||
const uInt32 maxTrailing = MAX_TRAILING;
|
||||
return min(getPropInt(props, SCORE_TRAILING_ZEROES, DEFAULT_TRAILING), MAX_TRAILING);
|
||||
|
||||
return min(uInt32(stringToInt(trailing, DEFAULT_TRAILING)), maxTrailing);
|
||||
//string trailing = getPropIdx(props, PropType::Cart_Formats, IDX_TRAILING_ZEROES);
|
||||
//const uInt32 maxTrailing = MAX_TRAILING;
|
||||
|
||||
//return min(uInt32(stringToInt(trailing, DEFAULT_TRAILING)), maxTrailing);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool HighScoresManager::scoreBCD(const Properties& props) const
|
||||
{
|
||||
string bcd = getPropIdx(props, PropType::Cart_Formats, IDX_SCORE_BCD);
|
||||
return getPropBool(props, SCORE_BCD, DEFAULT_SCORE_BCD);
|
||||
|
||||
return bcd.empty() ? DEFAULT_SCORE_BCD : bcd == "B";
|
||||
//string bcd = getPropIdx(props, PropType::Cart_Formats, IDX_SCORE_BCD);
|
||||
|
||||
//return bcd.empty() ? DEFAULT_SCORE_BCD : bcd == "B";
|
||||
}
|
||||
|
||||
bool HighScoresManager::scoreInvert(const Properties& props) const
|
||||
{
|
||||
string reversed = getPropIdx(props, PropType::Cart_Formats, IDX_SCORE_INVERT);
|
||||
return getPropBool(props, SCORE_INVERTED, DEFAULT_SCORE_REVERSED);
|
||||
|
||||
return reversed.empty() ? DEFAULT_SCORE_REVERSED : reversed != "0";
|
||||
//string reversed = getPropIdx(props, PropType::Cart_Formats, IDX_SCORE_INVERT);
|
||||
|
||||
//return reversed.empty() ? DEFAULT_SCORE_REVERSED : reversed != "0";
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool HighScoresManager::varBCD(const Properties& props) const
|
||||
{
|
||||
string bcd = getPropIdx(props, PropType::Cart_Formats, IDX_VAR_BCD);
|
||||
return getPropBool(props, VARIATIONS_BCD, DEFAULT_VARS_BCD);
|
||||
|
||||
return bcd.empty() ? DEFAULT_VARS_BCD : bcd == "B";
|
||||
//string bcd = getPropIdx(props, PropType::Cart_Formats, IDX_VAR_BCD);
|
||||
|
||||
//return bcd.empty() ? DEFAULT_VARS_BCD : bcd == "B";
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool HighScoresManager::varZeroBased(const Properties& props) const
|
||||
{
|
||||
string zeroBased = getPropIdx(props, PropType::Cart_Formats, IDX_VAR_ZERO_BASED);
|
||||
return getPropBool(props, VARIATIONS_ZERO_BASED, DEFAULT_VARS_ZERO_BASED);
|
||||
|
||||
return zeroBased.empty() ? DEFAULT_VARS_ZERO_BASED : zeroBased != "0";
|
||||
//string zeroBased = getPropIdx(props, PropType::Cart_Formats, IDX_VAR_ZERO_BASED);
|
||||
|
||||
//return zeroBased.empty() ? DEFAULT_VARS_ZERO_BASED : zeroBased != "0";
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string HighScoresManager::specialLabel(const Properties& props) const
|
||||
{
|
||||
return fromPropString(getPropIdx(props, PropType::Cart_Formats, IDX_SPECIAL_LABEL));
|
||||
return getPropStr(props, SPECIAL_LABEL);
|
||||
|
||||
//return fromPropString(getPropIdx(props, PropType::Cart_Formats, IDX_SPECIAL_LABEL));
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool HighScoresManager::specialBCD(const Properties& props) const
|
||||
{
|
||||
string bcd = getPropIdx(props, PropType::Cart_Formats, IDX_SPECIAL_BCD);
|
||||
return getPropBool(props, SPECIAL_BCD, DEFAULT_SPECIAL_BCD);
|
||||
|
||||
return bcd.empty() ? DEFAULT_SPECIAL_BCD : bcd == "B";
|
||||
//string bcd = getPropIdx(props, PropType::Cart_Formats, IDX_SPECIAL_BCD);
|
||||
|
||||
//return bcd.empty() ? DEFAULT_SPECIAL_BCD : bcd == "B";
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool HighScoresManager::specialZeroBased(const Properties& props) const
|
||||
{
|
||||
string zeroBased = getPropIdx(props, PropType::Cart_Formats, IDX_SPECIAL_ZERO_BASED);
|
||||
return getPropBool(props, SPECIAL_ZERO_BASED, DEFAULT_SPECIAL_ZERO_BASED);
|
||||
|
||||
return zeroBased.empty() ? DEFAULT_SPECIAL_ZERO_BASED : zeroBased != "0";
|
||||
//string zeroBased = getPropIdx(props, PropType::Cart_Formats, IDX_SPECIAL_ZERO_BASED);
|
||||
|
||||
//return zeroBased.empty() ? DEFAULT_SPECIAL_ZERO_BASED : zeroBased != "0";
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string HighScoresManager::notes(const Properties& props) const
|
||||
{
|
||||
return fromPropString(getPropIdx(props, PropType::Cart_Formats, IDX_NOTES));
|
||||
return getPropStr(props, NOTES);
|
||||
|
||||
//return fromPropString(getPropIdx(props, PropType::Cart_Formats, IDX_NOTES));
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -298,19 +388,23 @@ string HighScoresManager::notes(const Properties& props) const
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt16 HighScoresManager::varAddress(const Properties& props) const
|
||||
{
|
||||
uInt32 idx = numAddrBytes(props) + IDX_VARS_ADDRESS;
|
||||
string addr = getPropIdx(props, PropType::Cart_Addresses, idx);
|
||||
return getPropAddr(props, VARIATIONS_ADDRESS, DEFAULT_ADDRESS);
|
||||
|
||||
return stringToIntBase16(addr, DEFAULT_ADDRESS);
|
||||
//uInt32 idx = numAddrBytes(props) + IDX_VARS_ADDRESS;
|
||||
//string addr = getPropIdx(props, PropType::Cart_Addresses, idx);
|
||||
|
||||
//return stringToIntBase16(addr, DEFAULT_ADDRESS);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt16 HighScoresManager::specialAddress(const Properties& props) const
|
||||
{
|
||||
uInt32 idx = numAddrBytes(props) + IDX_SPECIAL_ADDRESS;
|
||||
string addr = getPropIdx(props, PropType::Cart_Addresses, idx);
|
||||
return getPropAddr(props, SPECIAL_ADDRESS, DEFAULT_ADDRESS);
|
||||
|
||||
return stringToIntBase16(addr, DEFAULT_ADDRESS);
|
||||
//uInt32 idx = numAddrBytes(props) + IDX_SPECIAL_ADDRESS;
|
||||
//string addr = getPropIdx(props, PropType::Cart_Addresses, idx);
|
||||
|
||||
//return stringToIntBase16(addr, DEFAULT_ADDRESS);
|
||||
}
|
||||
|
||||
|
||||
|
@ -411,15 +505,55 @@ Int32 HighScoresManager::score() const
|
|||
uInt32 numBytes = numAddrBytes(properties(props));
|
||||
ScoreAddresses scoreAddr;
|
||||
|
||||
for (uInt32 b = 0; b < numBytes; ++b)
|
||||
if(numBytes >= 1)
|
||||
{
|
||||
string addr = getPropIdx(props, PropType::Cart_Addresses, b);
|
||||
string addr = getPropStr(props, SCORE_ADDRESS_0);
|
||||
|
||||
if (addr.empty())
|
||||
if(addr.empty())
|
||||
return NO_VALUE;
|
||||
scoreAddr[b] = stringToIntBase16(addr);
|
||||
|
||||
scoreAddr[0] = getPropAddr(props, SCORE_ADDRESS_0);
|
||||
}
|
||||
|
||||
if(numBytes >= 2)
|
||||
{
|
||||
string addr = getPropStr(props, SCORE_ADDRESS_1);
|
||||
|
||||
if(addr.empty())
|
||||
return NO_VALUE;
|
||||
|
||||
scoreAddr[1] = getPropAddr(props, SCORE_ADDRESS_1);
|
||||
}
|
||||
|
||||
if(numBytes >= 3)
|
||||
{
|
||||
string addr = getPropStr(props, SCORE_ADDRESS_2);
|
||||
|
||||
if(addr.empty())
|
||||
return NO_VALUE;
|
||||
|
||||
scoreAddr[2] = getPropAddr(props, SCORE_ADDRESS_2);
|
||||
}
|
||||
|
||||
if(numBytes >= 4)
|
||||
{
|
||||
string addr = getPropStr(props, SCORE_ADDRESS_3);
|
||||
|
||||
if(addr.empty())
|
||||
return NO_VALUE;
|
||||
|
||||
scoreAddr[3] = getPropAddr(props, SCORE_ADDRESS_3);
|
||||
}
|
||||
|
||||
//for (uInt32 b = 0; b < numBytes; ++b)
|
||||
//{
|
||||
// string addr = getPropIdx(props, PropType::Cart_Addresses, b);
|
||||
|
||||
// if (addr.empty())
|
||||
// return NO_VALUE;
|
||||
// scoreAddr[b] = stringToIntBase16(addr);
|
||||
//}
|
||||
|
||||
return score(numBytes, trailingZeroes(props), scoreBCD(props), scoreAddr);
|
||||
}
|
||||
|
||||
|
@ -512,6 +646,78 @@ Int32 HighScoresManager::convert(Int32 val, uInt32 maxVal, bool isBCD, bool zero
|
|||
return val;
|
||||
}
|
||||
|
||||
void replaceAll(std::string& str, const std::string& from, const std::string& to) {
|
||||
if(from.empty())
|
||||
return;
|
||||
size_t start_pos = 0;
|
||||
while((start_pos = str.find(from, start_pos)) != std::string::npos) {
|
||||
str.replace(start_pos, from.length(), to);
|
||||
start_pos += to.length(); // In case 'to' contains 'from', like replacing 'x' with 'yx'
|
||||
}
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool HighScoresManager::getPropBool(const Properties& props, const string& key,
|
||||
bool defVal) const
|
||||
{
|
||||
const string& property = props.get(PropType::Cart_Highscore);
|
||||
|
||||
if(property.empty())
|
||||
return defVal;
|
||||
|
||||
const json hsProp = json::parse(property);
|
||||
|
||||
return hsProp.contains(key) ? hsProp.at(key).get<bool>() : defVal;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt32 HighScoresManager::getPropInt(const Properties& props, const string& key,
|
||||
uInt32 defVal) const
|
||||
{
|
||||
const string& property = props.get(PropType::Cart_Highscore);
|
||||
|
||||
if(property.empty())
|
||||
return defVal;
|
||||
|
||||
const json hsProp = json::parse(property);
|
||||
|
||||
return hsProp.contains(key) ? hsProp.at(key).get<uInt32>() : defVal;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string HighScoresManager::getPropStr(const Properties& props, const string& key,
|
||||
const string& defVal) const
|
||||
{
|
||||
const string& property = props.get(PropType::Cart_Highscore);
|
||||
|
||||
if(property.empty())
|
||||
return defVal;
|
||||
|
||||
const json hsProp = json::parse(property);
|
||||
|
||||
return hsProp.contains(key) ? hsProp.at(key).get<string>() : defVal;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt16 HighScoresManager::getPropAddr(const Properties& props, const string& key,
|
||||
uInt16 defVal) const
|
||||
{
|
||||
const string str = getPropStr(props, key);
|
||||
|
||||
return str.empty() ? defVal : fromHexStr(str);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt16 HighScoresManager::fromHexStr(const string& addr) const
|
||||
{
|
||||
string naked = addr;
|
||||
|
||||
if(int pos = naked.find("0x") != std::string::npos)
|
||||
naked = naked.substr(pos + 1);
|
||||
|
||||
return stringToIntBase16(naked);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Int32 HighScoresManager::fromBCD(uInt8 bcd) const
|
||||
{
|
||||
|
@ -557,3 +763,22 @@ string HighScoresManager::fromPropString(const string& text) const
|
|||
size_t start = result.find_first_not_of(" ");
|
||||
return (start == std::string::npos) ? "" : result.substr(start);
|
||||
}
|
||||
|
||||
const string HighScoresManager::VARIATIONS_COUNT = "variations_number";
|
||||
const string HighScoresManager::VARIATIONS_ADDRESS = "variations_address";
|
||||
const string HighScoresManager::VARIATIONS_BCD = "variations_bcd";
|
||||
const string HighScoresManager::VARIATIONS_ZERO_BASED = "variations_zero_based";
|
||||
const string HighScoresManager::SCORE_DIGITS = "score_digits";
|
||||
const string HighScoresManager::SCORE_TRAILING_ZEROES = "score_trailing_zeroes";
|
||||
const string HighScoresManager::SCORE_BCD = "score_bcd";
|
||||
const string HighScoresManager::SCORE_INVERTED = "score_inverted";
|
||||
const string HighScoresManager::SCORE_ADDRESSES = "score_addresses";
|
||||
const string HighScoresManager::SCORE_ADDRESS_0 = "score_address_0";
|
||||
const string HighScoresManager::SCORE_ADDRESS_1 = "score_address_1";
|
||||
const string HighScoresManager::SCORE_ADDRESS_2 = "score_address_2";
|
||||
const string HighScoresManager::SCORE_ADDRESS_3 = "score_address_3";
|
||||
const string HighScoresManager::SPECIAL_LABEL = "special_label";
|
||||
const string HighScoresManager::SPECIAL_ADDRESS = "special_address";
|
||||
const string HighScoresManager::SPECIAL_BCD = "special_bcd";
|
||||
const string HighScoresManager::SPECIAL_ZERO_BASED = "special_zero_based";
|
||||
const string HighScoresManager::NOTES = "notes";
|
||||
|
|
|
@ -129,23 +129,42 @@ class HighScoresManager
|
|||
Int16 peek(uInt16 addr) const;
|
||||
|
||||
private:
|
||||
enum {
|
||||
//IDX_ARM_RAM = 0,
|
||||
IDX_SCORE_DIGITS = 0,
|
||||
IDX_TRAILING_ZEROES,
|
||||
IDX_SCORE_BCD,
|
||||
IDX_SCORE_INVERT,
|
||||
IDX_VAR_BCD,
|
||||
IDX_VAR_ZERO_BASED,
|
||||
IDX_SPECIAL_LABEL,
|
||||
IDX_SPECIAL_BCD,
|
||||
IDX_SPECIAL_ZERO_BASED,
|
||||
IDX_NOTES,
|
||||
};
|
||||
enum {
|
||||
IDX_VARS_ADDRESS = 0,
|
||||
IDX_SPECIAL_ADDRESS
|
||||
};
|
||||
//enum {
|
||||
// //IDX_ARM_RAM = 0,
|
||||
// IDX_SCORE_DIGITS = 0,
|
||||
// IDX_TRAILING_ZEROES,
|
||||
// IDX_SCORE_BCD,
|
||||
// IDX_SCORE_INVERT,
|
||||
// IDX_VAR_BCD,
|
||||
// IDX_VAR_ZERO_BASED,
|
||||
// IDX_SPECIAL_LABEL,
|
||||
// IDX_SPECIAL_BCD,
|
||||
// IDX_SPECIAL_ZERO_BASED,
|
||||
// IDX_NOTES,
|
||||
//};
|
||||
//enum {
|
||||
// IDX_VARS_ADDRESS = 0,
|
||||
// IDX_SPECIAL_ADDRESS
|
||||
//};
|
||||
|
||||
static const string VARIATIONS_COUNT;
|
||||
static const string VARIATIONS_ADDRESS;
|
||||
static const string VARIATIONS_BCD;
|
||||
static const string VARIATIONS_ZERO_BASED;
|
||||
static const string SCORE_DIGITS;
|
||||
static const string SCORE_TRAILING_ZEROES;
|
||||
static const string SCORE_BCD;
|
||||
static const string SCORE_INVERTED;
|
||||
static const string SCORE_ADDRESSES;
|
||||
static const string SCORE_ADDRESS_0;
|
||||
static const string SCORE_ADDRESS_1;
|
||||
static const string SCORE_ADDRESS_2;
|
||||
static const string SCORE_ADDRESS_3;
|
||||
static const string SPECIAL_LABEL;
|
||||
static const string SPECIAL_ADDRESS;
|
||||
static const string SPECIAL_BCD;
|
||||
static const string SPECIAL_ZERO_BASED;
|
||||
static const string NOTES;
|
||||
|
||||
static constexpr uInt32 MAX_VARIATIONS = 256;
|
||||
|
||||
|
@ -177,14 +196,25 @@ class HighScoresManager
|
|||
string notes(const Properties& props) const;
|
||||
//bool armRAM(const Properties& props) const;
|
||||
|
||||
|
||||
// Calculate the number of bytes for one player's score from property parameters
|
||||
uInt32 numAddrBytes(const Properties& props) const;
|
||||
|
||||
// Get properties
|
||||
Properties& properties(Properties& props) const;
|
||||
// Get value from highscore propterties at given index
|
||||
string getPropIdx(const Properties& props, PropType type, uInt32 idx = 0) const;
|
||||
//// Get value from highscore propterties at given index
|
||||
//string getPropIdx(const Properties& props, PropType type, uInt32 idx = 0) const;
|
||||
|
||||
bool getPropBool(const Properties& props, const string& key,
|
||||
bool defVal = false) const;
|
||||
uInt32 getPropInt(const Properties& props, const string& key,
|
||||
uInt32 defVal = 0) const;
|
||||
string getPropStr(const Properties& props, const string& key,
|
||||
const string& defVal = "") const;
|
||||
uInt16 getPropAddr(const Properties& props, const string& key,
|
||||
uInt16 defVal = 0) const;
|
||||
|
||||
uInt16 fromHexStr(const string& addr) const;
|
||||
Int32 fromBCD(uInt8 bcd) const;
|
||||
string toPropString(const string& test) const;
|
||||
string fromPropString(const string& test) const;
|
||||
|
|
|
@ -66,7 +66,7 @@ void JoyMap::erase(const EventMode mode, const int button,
|
|||
Event::Type JoyMap::get(const JoyMapping& mapping) const
|
||||
{
|
||||
auto find = myMap.find(mapping);
|
||||
if (find != myMap.end())
|
||||
if(find != myMap.end())
|
||||
return find->second;
|
||||
|
||||
// try without button as modifier
|
||||
|
@ -75,7 +75,7 @@ Event::Type JoyMap::get(const JoyMapping& mapping) const
|
|||
m.button = JOY_CTRL_NONE;
|
||||
|
||||
find = myMap.find(m);
|
||||
if (find != myMap.end())
|
||||
if(find != myMap.end())
|
||||
return find->second;
|
||||
|
||||
return Event::Type::NoType;
|
||||
|
@ -96,7 +96,7 @@ Event::Type JoyMap::get(const EventMode mode, const int button,
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool JoyMap::check(const JoyMapping & mapping) const
|
||||
bool JoyMap::check(const JoyMapping& mapping) const
|
||||
{
|
||||
auto find = myMap.find(mapping);
|
||||
|
||||
|
@ -117,14 +117,14 @@ string JoyMap::getDesc(const Event::Type event, const JoyMapping& mapping) const
|
|||
ostringstream buf;
|
||||
|
||||
// button description
|
||||
if (mapping.button != JOY_CTRL_NONE)
|
||||
if(mapping.button != JOY_CTRL_NONE)
|
||||
buf << "/B" << mapping.button;
|
||||
|
||||
// axis description
|
||||
if (mapping.axis != JoyAxis::NONE)
|
||||
if(mapping.axis != JoyAxis::NONE)
|
||||
{
|
||||
buf << "/A";
|
||||
switch (mapping.axis)
|
||||
switch(mapping.axis)
|
||||
{
|
||||
case JoyAxis::X: buf << "X"; break;
|
||||
case JoyAxis::Y: buf << "Y"; break;
|
||||
|
@ -132,19 +132,19 @@ string JoyMap::getDesc(const Event::Type event, const JoyMapping& mapping) const
|
|||
default: buf << int(mapping.axis); break;
|
||||
}
|
||||
|
||||
if (Event::isAnalog(event))
|
||||
if(Event::isAnalog(event))
|
||||
buf << "+|-";
|
||||
else if (mapping.adir == JoyDir::NEG)
|
||||
else if(mapping.adir == JoyDir::NEG)
|
||||
buf << "-";
|
||||
else
|
||||
buf << "+";
|
||||
}
|
||||
|
||||
// hat description
|
||||
if (mapping.hat != JOY_CTRL_NONE)
|
||||
if(mapping.hat != JOY_CTRL_NONE)
|
||||
{
|
||||
buf << "/H" << mapping.hat;
|
||||
switch (mapping.hdir)
|
||||
switch(mapping.hdir)
|
||||
{
|
||||
case JoyHatDir::UP: buf << "Y+"; break;
|
||||
case JoyHatDir::DOWN: buf << "Y-"; break;
|
||||
|
@ -162,11 +162,11 @@ string JoyMap::getEventMappingDesc(int stick, const Event::Type event, const Eve
|
|||
{
|
||||
ostringstream buf;
|
||||
|
||||
for (auto item : myMap)
|
||||
for(auto item : myMap)
|
||||
{
|
||||
if (item.second == event && item.first.mode == mode)
|
||||
if(item.second == event && item.first.mode == mode)
|
||||
{
|
||||
if (buf.str() != "")
|
||||
if(buf.str() != "")
|
||||
buf << ", ";
|
||||
buf << "J" << stick << getDesc(event, item.first);
|
||||
}
|
||||
|
@ -179,8 +179,8 @@ JoyMap::JoyMappingArray JoyMap::getEventMapping(const Event::Type event, const E
|
|||
{
|
||||
JoyMappingArray map;
|
||||
|
||||
for (auto item : myMap)
|
||||
if (item.second == event && item.first.mode == mode)
|
||||
for(auto item : myMap)
|
||||
if(item.second == event && item.first.mode == mode)
|
||||
map.push_back(item.first);
|
||||
|
||||
return map;
|
||||
|
@ -191,21 +191,21 @@ json JoyMap::saveMapping(const EventMode mode) const
|
|||
{
|
||||
json eventMappings = json::array();
|
||||
|
||||
for (auto& item: myMap) {
|
||||
if (item.first.mode != mode) continue;
|
||||
for(auto& item : myMap) {
|
||||
if(item.first.mode != mode) continue;
|
||||
|
||||
json eventMapping = json::object();
|
||||
|
||||
eventMapping["event"] = item.second;
|
||||
|
||||
if (item.first.button != JOY_CTRL_NONE) eventMapping["button"] = item.first.button;
|
||||
if(item.first.button != JOY_CTRL_NONE) eventMapping["button"] = item.first.button;
|
||||
|
||||
if (item.first.axis != JoyAxis::NONE) {
|
||||
if(item.first.axis != JoyAxis::NONE) {
|
||||
eventMapping["axis"] = item.first.axis;
|
||||
eventMapping["axisDirection"] = item.first.adir;
|
||||
}
|
||||
|
||||
if (item.first.hat != -1) {
|
||||
if(item.first.hat != -1) {
|
||||
eventMapping["hat"] = item.first.hat;
|
||||
eventMapping["hatDirection"] = item.first.hdir;
|
||||
}
|
||||
|
@ -221,7 +221,7 @@ int JoyMap::loadMapping(const json& eventMappings, const EventMode mode)
|
|||
{
|
||||
int i = 0;
|
||||
|
||||
for (const json& eventMapping: eventMappings) {
|
||||
for(const json& eventMapping : eventMappings) {
|
||||
int button = eventMapping.contains("button") ? eventMapping.at("button").get<int>() : JOY_CTRL_NONE;
|
||||
JoyAxis axis = eventMapping.contains("axis") ? eventMapping.at("axis").get<JoyAxis>() : JoyAxis::NONE;
|
||||
JoyDir axisDirection = eventMapping.contains("axis") ? eventMapping.at("axisDirection").get<JoyDir>() : JoyDir::NONE;
|
||||
|
@ -240,7 +240,8 @@ int JoyMap::loadMapping(const json& eventMappings, const EventMode mode)
|
|||
);
|
||||
|
||||
i++;
|
||||
} catch (json::exception) {
|
||||
}
|
||||
catch(json::exception) {
|
||||
Logger::error("ignoring invalid joystick event");
|
||||
}
|
||||
}
|
||||
|
@ -262,22 +263,22 @@ json JoyMap::convertLegacyMapping(string list)
|
|||
istringstream buf(list);
|
||||
int event, button, axis, adir, hat, hdir;
|
||||
|
||||
while (buf >> event && buf >> button
|
||||
&& buf >> axis && buf >> adir
|
||||
&& buf >> hat && buf >> hdir)
|
||||
while(buf >> event && buf >> button
|
||||
&& buf >> axis && buf >> adir
|
||||
&& buf >> hat && buf >> hdir)
|
||||
{
|
||||
json eventMapping = json::object();
|
||||
|
||||
eventMapping["event"] = Event::Type(event);
|
||||
|
||||
if (button != JOY_CTRL_NONE) eventMapping["button"] = button;
|
||||
if(button != JOY_CTRL_NONE) eventMapping["button"] = button;
|
||||
|
||||
if (JoyAxis(axis) != JoyAxis::NONE) {
|
||||
if(JoyAxis(axis) != JoyAxis::NONE) {
|
||||
eventMapping["axis"] = JoyAxis(axis);
|
||||
eventMapping["axisDirection"] = JoyDir(adir);
|
||||
}
|
||||
|
||||
if (hat != -1) {
|
||||
if(hat != -1) {
|
||||
eventMapping["hat"] = hat;
|
||||
eventMapping["hatDirection"] = JoyHatDir(hdir);
|
||||
}
|
||||
|
@ -291,8 +292,8 @@ json JoyMap::convertLegacyMapping(string list)
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void JoyMap::eraseMode(const EventMode mode)
|
||||
{
|
||||
for (auto item = myMap.begin(); item != myMap.end();)
|
||||
if (item->first.mode == mode) {
|
||||
for(auto item = myMap.begin(); item != myMap.end();)
|
||||
if(item->first.mode == mode) {
|
||||
auto _item = item++;
|
||||
erase(_item->first);
|
||||
}
|
||||
|
@ -302,8 +303,8 @@ void JoyMap::eraseMode(const EventMode mode)
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void JoyMap::eraseEvent(const Event::Type event, const EventMode mode)
|
||||
{
|
||||
for (auto item = myMap.begin(); item != myMap.end();)
|
||||
if (item->second == event && item->first.mode == mode) {
|
||||
for(auto item = myMap.begin(); item != myMap.end();)
|
||||
if(item->second == event && item->first.mode == mode) {
|
||||
auto _item = item++;
|
||||
erase(_item->first);
|
||||
}
|
||||
|
|
|
@ -51,10 +51,10 @@ Event::Type KeyMap::get(const Mapping& mapping) const
|
|||
{
|
||||
Mapping m = convertMod(mapping);
|
||||
|
||||
if (myModEnabled)
|
||||
if(myModEnabled)
|
||||
{
|
||||
auto find = myMap.find(m);
|
||||
if (find != myMap.end())
|
||||
if(find != myMap.end())
|
||||
return find->second;
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ Event::Type KeyMap::get(const Mapping& mapping) const
|
|||
m.mod = StellaMod(0);
|
||||
|
||||
auto find = myMap.find(m);
|
||||
if (find != myMap.end())
|
||||
if(find != myMap.end())
|
||||
return find->second;
|
||||
|
||||
return Event::Type::NoType;
|
||||
|
@ -112,26 +112,26 @@ string KeyMap::getDesc(const Mapping& mapping) const
|
|||
int RMOD3 = KBDM_RALT;
|
||||
#endif
|
||||
|
||||
if ((mapping.mod & KBDM_CTRL) == KBDM_CTRL) buf << "Ctrl";
|
||||
else if (mapping.mod & KBDM_LCTRL) buf << "Left Ctrl";
|
||||
else if (mapping.mod & KBDM_RCTRL) buf << "Right Ctrl";
|
||||
if((mapping.mod & KBDM_CTRL) == KBDM_CTRL) buf << "Ctrl";
|
||||
else if(mapping.mod & KBDM_LCTRL) buf << "Left Ctrl";
|
||||
else if(mapping.mod & KBDM_RCTRL) buf << "Right Ctrl";
|
||||
|
||||
if ((mapping.mod & (MOD2)) && buf.tellp()) buf << "+";
|
||||
if ((mapping.mod & MOD2) == MOD2) buf << mod2;
|
||||
else if (mapping.mod & LMOD2) buf << "Left " << mod2;
|
||||
else if (mapping.mod & RMOD2) buf << "Right " << mod2;
|
||||
if((mapping.mod & (MOD2)) && buf.tellp()) buf << "+";
|
||||
if((mapping.mod & MOD2) == MOD2) buf << mod2;
|
||||
else if(mapping.mod & LMOD2) buf << "Left " << mod2;
|
||||
else if(mapping.mod & RMOD2) buf << "Right " << mod2;
|
||||
|
||||
if ((mapping.mod & (MOD3)) && buf.tellp()) buf << "+";
|
||||
if ((mapping.mod & MOD3) == MOD3) buf << mod3;
|
||||
else if (mapping.mod & LMOD3) buf << "Left " << mod3;
|
||||
else if (mapping.mod & RMOD3) buf << "Right " << mod3;
|
||||
if((mapping.mod & (MOD3)) && buf.tellp()) buf << "+";
|
||||
if((mapping.mod & MOD3) == MOD3) buf << mod3;
|
||||
else if(mapping.mod & LMOD3) buf << "Left " << mod3;
|
||||
else if(mapping.mod & RMOD3) buf << "Right " << mod3;
|
||||
|
||||
if ((mapping.mod & (KBDM_SHIFT)) && buf.tellp()) buf << "+";
|
||||
if ((mapping.mod & KBDM_SHIFT) == KBDM_SHIFT) buf << "Shift";
|
||||
else if (mapping.mod & KBDM_LSHIFT) buf << "Left Shift";
|
||||
else if (mapping.mod & KBDM_RSHIFT) buf << "Right Shift";
|
||||
if((mapping.mod & (KBDM_SHIFT)) && buf.tellp()) buf << "+";
|
||||
if((mapping.mod & KBDM_SHIFT) == KBDM_SHIFT) buf << "Shift";
|
||||
else if(mapping.mod & KBDM_LSHIFT) buf << "Left Shift";
|
||||
else if(mapping.mod & KBDM_RSHIFT) buf << "Right Shift";
|
||||
|
||||
if (buf.tellp()) buf << "+";
|
||||
if(buf.tellp()) buf << "+";
|
||||
buf << StellaKeyName::forKey(mapping.key);
|
||||
|
||||
return buf.str();
|
||||
|
@ -148,11 +148,11 @@ string KeyMap::getEventMappingDesc(const Event::Type event, const EventMode mode
|
|||
{
|
||||
ostringstream buf;
|
||||
|
||||
for (auto item : myMap)
|
||||
for(auto item : myMap)
|
||||
{
|
||||
if (item.second == event && item.first.mode == mode)
|
||||
if(item.second == event && item.first.mode == mode)
|
||||
{
|
||||
if (buf.str() != "")
|
||||
if(buf.str() != "")
|
||||
buf << ", ";
|
||||
buf << getDesc(item.first);
|
||||
}
|
||||
|
@ -165,8 +165,8 @@ KeyMap::MappingArray KeyMap::getEventMapping(const Event::Type event, const Even
|
|||
{
|
||||
MappingArray map;
|
||||
|
||||
for (auto item : myMap)
|
||||
if (item.second == event && item.first.mode == mode)
|
||||
for(auto item : myMap)
|
||||
if(item.second == event && item.first.mode == mode)
|
||||
map.push_back(item.first);
|
||||
|
||||
return map;
|
||||
|
@ -177,15 +177,16 @@ json KeyMap::saveMapping(const EventMode mode) const
|
|||
{
|
||||
json mappings = json::array();
|
||||
|
||||
for (auto item : myMap) {
|
||||
if (item.first.mode != mode) continue;
|
||||
for(auto item : myMap)
|
||||
{
|
||||
if(item.first.mode != mode) continue;
|
||||
|
||||
json mapping = json::object();
|
||||
|
||||
mapping["event"] = item.second;
|
||||
mapping["key"] = item.first.key;
|
||||
|
||||
if (item.first.mod != StellaMod::KBDM_NONE)
|
||||
if(item.first.mod != StellaMod::KBDM_NONE)
|
||||
mapping["mod"] = item.first.mod;
|
||||
|
||||
mappings.push_back(mapping);
|
||||
|
@ -198,7 +199,8 @@ json KeyMap::saveMapping(const EventMode mode) const
|
|||
int KeyMap::loadMapping(const json& mappings, const EventMode mode) {
|
||||
int i = 0;
|
||||
|
||||
for (const json& mapping: mappings) {
|
||||
for(const json& mapping : mappings)
|
||||
{
|
||||
try {
|
||||
add(
|
||||
mapping.at("event").get<Event::Type>(),
|
||||
|
@ -208,7 +210,8 @@ int KeyMap::loadMapping(const json& mappings, const EventMode mode) {
|
|||
);
|
||||
|
||||
i++;
|
||||
} catch (json::exception) {
|
||||
}
|
||||
catch(json::exception) {
|
||||
Logger::error("ignoring bad keyboard mapping");
|
||||
}
|
||||
}
|
||||
|
@ -229,13 +232,14 @@ json KeyMap::convertLegacyMapping(string list)
|
|||
istringstream buf(list);
|
||||
int event, key, mod;
|
||||
|
||||
while (buf >> event && buf >> key && buf >> mod) {
|
||||
while(buf >> event && buf >> key && buf >> mod)
|
||||
{
|
||||
json mapping = json::object();
|
||||
|
||||
mapping["event"] = Event::Type(event);
|
||||
mapping["key"] = StellaKey(key);
|
||||
|
||||
if (StellaMod(mod) != StellaMod::KBDM_NONE) mapping["mod"] = StellaMod(mod);
|
||||
if(StellaMod(mod) != StellaMod::KBDM_NONE) mapping["mod"] = StellaMod(mod);
|
||||
|
||||
convertedMapping.push_back(mapping);
|
||||
}
|
||||
|
@ -246,8 +250,8 @@ json KeyMap::convertLegacyMapping(string list)
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void KeyMap::eraseMode(const EventMode mode)
|
||||
{
|
||||
for (auto item = myMap.begin(); item != myMap.end();)
|
||||
if (item->first.mode == mode) {
|
||||
for(auto item = myMap.begin(); item != myMap.end();)
|
||||
if(item->first.mode == mode) {
|
||||
auto _item = item++;
|
||||
erase(_item->first);
|
||||
}
|
||||
|
@ -257,8 +261,8 @@ void KeyMap::eraseMode(const EventMode mode)
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void KeyMap::eraseEvent(const Event::Type event, const EventMode mode)
|
||||
{
|
||||
for (auto item = myMap.begin(); item != myMap.end();)
|
||||
if (item->second == event && item->first.mode == mode) {
|
||||
for(auto item = myMap.begin(); item != myMap.end();)
|
||||
if(item->second == event && item->first.mode == mode) {
|
||||
auto _item = item++;
|
||||
erase(_item->first);
|
||||
}
|
||||
|
@ -270,7 +274,7 @@ KeyMap::Mapping KeyMap::convertMod(const Mapping& mapping) const
|
|||
{
|
||||
Mapping m = mapping;
|
||||
|
||||
if (m.key >= KBDK_LCTRL && m.key <= KBDK_RGUI)
|
||||
if(m.key >= KBDK_LCTRL && m.key <= KBDK_RGUI)
|
||||
// handle solo modifier keys differently
|
||||
m.mod = KBDM_NONE;
|
||||
else
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -270,7 +270,8 @@ void Properties::print() const
|
|||
<< get(PropType::Display_PPBlend) << "|"
|
||||
<< get(PropType::Cart_Variations) << "|"
|
||||
<< get(PropType::Cart_Formats) << "|"
|
||||
<< get(PropType::Cart_Addresses)
|
||||
<< get(PropType::Cart_Addresses) << "|"
|
||||
<< get(PropType::Cart_Highscore)
|
||||
<< endl;
|
||||
}
|
||||
|
||||
|
@ -332,7 +333,8 @@ void Properties::printHeader()
|
|||
<< "Display_PPBlend|"
|
||||
<< "Cart_Variations|"
|
||||
<< "Cart_Formats|"
|
||||
<< "Cart_Addresses"
|
||||
<< "Cart_Addresses|"
|
||||
<< "Cart_Highscore"
|
||||
<< endl;
|
||||
}
|
||||
|
||||
|
@ -368,7 +370,8 @@ std::array<string, Properties::NUM_PROPS> Properties::ourDefaultProperties =
|
|||
"0", // Display.PPBlend
|
||||
"1", // Cart.Variations
|
||||
"", // Cart.Formats,
|
||||
"" // Cart.Addresses
|
||||
"", // Cart.Addresses
|
||||
"" // Cart.Highscore
|
||||
};
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -403,5 +406,6 @@ std::array<string, Properties::NUM_PROPS> Properties::ourPropertyNames =
|
|||
"Display.PPBlend",
|
||||
"Cart.Variations",
|
||||
"Cart.Formats",
|
||||
"Cart.Addresses"
|
||||
"Cart.Addresses",
|
||||
"Cart.Highscore"
|
||||
};
|
||||
|
|
|
@ -51,6 +51,7 @@ enum class PropType : uInt8 {
|
|||
Cart_Variations,
|
||||
Cart_Formats,
|
||||
Cart_Addresses,
|
||||
Cart_Highscore,
|
||||
NumTypes
|
||||
};
|
||||
|
||||
|
|
|
@ -473,7 +473,7 @@ void GameInfoDialog::addHighScoresTab()
|
|||
const int HBORDER = fontWidth * 1.25;
|
||||
const int VGAP = fontHeight / 4;
|
||||
|
||||
int xpos, ypos, lwidth, fwidth, pwidth, tabID;
|
||||
int xpos, ypos, lwidth, pwidth, tabID;
|
||||
WidgetArray wid;
|
||||
VariantList items;
|
||||
|
||||
|
@ -503,14 +503,13 @@ void GameInfoDialog::addHighScoresTab()
|
|||
|
||||
ypos += lineHeight + VGAP;*/
|
||||
|
||||
pwidth = _font.getStringWidth("4");
|
||||
pwidth = _font.getStringWidth("4"); // popup
|
||||
|
||||
int awidth = _font.getMaxCharWidth() * HSM::MAX_ADDR_CHARS + 4;
|
||||
int vwidth = _font.getStringWidth("123") + 4;
|
||||
int awidth = EditTextWidget::calcWidth(_font, HSM::MAX_ADDR_CHARS); // addresses
|
||||
int vwidth = EditTextWidget::calcWidth(_font, 3); // values
|
||||
int swidth = EditTextWidget::calcWidth(_font, HSM::MAX_SPECIAL_NAME); // special
|
||||
int fwidth = EditTextWidget::calcWidth(_font, 3); // variants
|
||||
|
||||
fwidth = _font.getStringWidth("255") + 5;
|
||||
vwidth = _font.getStringWidth("123") + 4;
|
||||
int swidth = _font.getStringWidth("abcde") + 4;
|
||||
myVariationsLabel = new StaticTextWidget(myTab, _font, xpos, ypos + 1, lwidth, fontHeight,
|
||||
"Variations");
|
||||
myVariations = new EditTextWidget(myTab, _font, xpos + lwidth, ypos - 1, fwidth, lineHeight);
|
||||
|
|
|
@ -32,7 +32,8 @@ my %prop_type = (
|
|||
"Display.PPBlend" => 26,
|
||||
"Cart.Variations" => 27,
|
||||
"Cart.Formats" => 28,
|
||||
"Cart.Addresses" => 29
|
||||
"Cart.Addresses" => 29,
|
||||
"Cart.Highscore" => 30
|
||||
);
|
||||
my @prop_type_as_string = (
|
||||
"Cart.MD5",
|
||||
|
@ -63,7 +64,8 @@ my @prop_type_as_string = (
|
|||
"Display.PPBlend",
|
||||
"Cart.Variations",
|
||||
"Cart.Formats",
|
||||
"Cart.Addresses"
|
||||
"Cart.Addresses",
|
||||
"Cart_Highscore"
|
||||
);
|
||||
|
||||
my @prop_defaults = (
|
||||
|
@ -96,7 +98,8 @@ my @prop_defaults = (
|
|||
"0", # Display.PPBlend
|
||||
"1", # Cart.Variations
|
||||
"", # Cart.Formats
|
||||
"" # Cart.Addresses
|
||||
"", # Cart.Addresses
|
||||
"" # Cart.Highscore
|
||||
);
|
||||
|
||||
# Load and parse a properties file into an hash table of property
|
||||
|
|
Loading…
Reference in New Issue