add high score notes

This commit is contained in:
thrust26 2020-02-24 11:19:20 +01:00
parent 9a40428db3
commit 35bad97485
7 changed files with 182 additions and 57 deletions

View File

@ -140,6 +140,7 @@ bool HighScoresManager::get(const Properties& props, uInt32& numVariationsR,
info.special = specialLabel(props);
info.specialBCD = specialBCD(props);
info.specialZeroBased = specialZeroBased(props);
info.notes = notes(props);
info.varsAddr = varAddress(props);
info.specialAddr = specialAddress(props);
@ -164,12 +165,15 @@ void HighScoresManager::set(Properties& props, uInt32 numVariations,
props.set(PropType::Cart_Variations, to_string(min(numVariations, MAX_VARIATIONS)));
// fill from the back to skip default values
if (output.length() || !info.notes.empty())
output.insert(0, "," + toPropString(info.notes));
if (output.length() || info.specialZeroBased != DEFAULT_SPECIAL_ZERO_BASED)
output.insert(0, info.specialZeroBased ? ",1" : ",0");
if (output.length() || info.specialBCD != DEFAULT_SPECIAL_BCD)
output.insert(0, info.specialBCD ? ",B" : ",D");
if (output.length() || !info.special.empty())
output.insert(0, "," + (info.special.empty() ? "-" : info.special));
output.insert(0, "," + toPropString(info.special.empty() ? "_" : info.special));
if (output.length() || info.varsZeroBased != DEFAULT_VARS_ZERO_BASED)
output.insert(0, info.varsZeroBased ? ",1" : ",0");
@ -253,14 +257,7 @@ bool HighScoresManager::varZeroBased(const Properties& props) const
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string HighScoresManager::specialLabel(const Properties& props) const
{
string orgLabel, label;
// some ugly formatting
orgLabel = label = getPropIdx(props, PropType::Cart_Formats, IDX_SPECIAL_LABEL);
label = BSPF::toLowerCase(label);
label[0] = orgLabel[0];
return label;
return fromPropString(getPropIdx(props, PropType::Cart_Formats, IDX_SPECIAL_LABEL));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -279,6 +276,12 @@ bool HighScoresManager::specialZeroBased(const Properties& props) const
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));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/*bool HighScoresManager::armRAM(const Properties& props) const
{
@ -474,6 +477,14 @@ Int32 HighScoresManager::special(uInt16 addr, bool varBCD, bool zeroBased) const
return var;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string HighScoresManager::notes() const
{
Properties props;
return notes(properties(props));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Int32 HighScoresManager::convert(uInt32 val, uInt32 maxVal, bool isBCD, bool zeroBased) const
{
@ -505,3 +516,35 @@ Int32 HighScoresManager::fromBCD(uInt8 bcd) const
return (bcd >> 4) * 10 + bcd % 16;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string HighScoresManager::toPropString(const string& text) const
{
string result = text;
size_t pos;
while ((pos = result.find(" ")) != std::string::npos) {
result.replace(pos, 1, "_");
}
return result;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string HighScoresManager::fromPropString(const string& text) const
{
string result = text;
size_t pos;
while ((pos = result.find("_")) != std::string::npos) {
result.replace(pos, 1, " ");
}
// some ugly formatting
char first = result[0];
result = BSPF::toLowerCase(result);
result[0] = first;
return result;
}

View File

@ -53,6 +53,7 @@ namespace HSM {
string special;
bool specialBCD;
bool specialZeroBased;
string notes;
//bool armRAM;
// Addresses
ScoreAddresses scoreAddr;
@ -121,6 +122,7 @@ class HighScoresManager
string formattedScore(Int32 score, Int32 width = -1) const;
bool scoreInvert() const;
Int32 special() const;
string notes() const;
// converts the given value, using only the maximum bits required by maxVal
// and adjusted for BCD and zero based data
@ -141,6 +143,7 @@ class HighScoresManager
IDX_SPECIAL_LABEL,
IDX_SPECIAL_BCD,
IDX_SPECIAL_ZERO_BASED,
IDX_NOTES,
};
enum {
IDX_VARS_ADDRESS = 0,
@ -174,6 +177,7 @@ class HighScoresManager
string specialLabel(const Properties& props) const;
bool specialBCD(const Properties& props) const;
bool specialZeroBased(const Properties& props) const;
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
@ -185,6 +189,8 @@ class HighScoresManager
string getPropIdx(const Properties& props, PropType type, uInt32 idx = 0) const;
Int32 fromBCD(uInt8 bcd) const;
string toPropString(const string& test) const;
string fromPropString(const string& test) const;
private:
// Reference to the osystem object

View File

@ -2,7 +2,7 @@
"Cart.Name" "draconian_20171013_RC6"
"Display.Phosphor" "YES"
"Cart.Variations" "4"
"Cart.Formats" "8,0,B,0,B,1,SECT.,D,1"
"Cart.Formats" "8,0,B,0,B,1,SECT.,D,1,VARIATIONS_ARE_DIFFICULTY_LEVEL"
"Cart.Addresses" "177B,177A,1779,1778,811,1780"
""
@ -47,7 +47,7 @@
"Cart.Manufacturer" "Activision, Steve Cartwright"
"Cart.ModelNo" "AX-022"
"Cart.Name" "Seaquest (1983) (Activision)"
"Cart.Formats" "6"
"Cart.Formats" "6,0,B,0,B,0,_,B,0,HIGH_SCORE_IS_FROM_CURRENT_PLAYER"
"Cart.Addresses" "B8,B9,BA"
""
@ -61,6 +61,15 @@
"Cart.Addresses" "FD,FE,FF,FC"
""
"Cart.MD5" "2903896d88a341511586d69fcfc20f7d"
"Cart.Manufacturer" "Activision, David Crane"
"Cart.ModelNo" "AX-014, AX-014-04"
"Cart.Name" "Grand Prix (1982) (Activision)"
"Cart.Variations" "4"
"Cart.Formats" "5,0,B,1,B,1,_,B,0,TIME/SCORE_SHOWS_EXTRA_DIGIT"
"Cart.Addresses" "EB,EC,ED,80"
""
"Cart.MD5" "2a0ba55e56e7a596146fa729acf0e109"
"Cart.Manufacturer" "Activision, Bob Whitehead"
"Cart.ModelNo" "AG-019"
@ -115,6 +124,15 @@
"Cart.Addresses" "D5,D6,D7"
""
"Cart.MD5" "4ca73eb959299471788f0b685c3ba0b5"
"Cart.Manufacturer" "Activision, Steve Cartwright"
"Cart.ModelNo" "AX-031"
"Cart.Name" "Frostbite (1983) (Activision)"
"Cart.Variations" "4"
"Cart.Formats" "6,0,B,0,B,1,LEVEL,B,1"
"Cart.Addresses" "C8,C9,CA,80,CB"
""
"Cart.MD5" "515046e3061b7b18aa3a551c3ae12673"
"Cart.Manufacturer" "Atari - GCC, Mark Ackerman, Noellie Alito"
"Cart.ModelNo" "CX2692"
@ -135,7 +153,9 @@
"Cart.Manufacturer" "Atari - GCC, Douglas B. Macrae"
"Cart.ModelNo" "CX2677"
"Cart.Name" "Dig Dug (1983) (Atari)"
"Cart.Addresses" "F0FE,F0FD"
"Cart.Variations" "2"
"Cart.Formats" "4,0,B,0,B,1,_,B,0,VARIATION_1_IS_EASY;_2_IS_NORMAL"
"Cart.Addresses" "F0FE,F0FD,80"
""
"Cart.MD5" "72ffbef6504b75e69ee1045af9075f66"
@ -143,7 +163,7 @@
"Cart.ModelNo" "CX2632 - 49-75153"
"Cart.Name" "Space Invaders (1980) (Atari)"
"Cart.Variations" "112"
"Cart.Formats" "4,0,B,0,H,1"
"Cart.Formats" "4,0,B,0,D,1,_,B,0,ONLY_PLAYER_1_SUPPORTED"
"Cart.Addresses" "E6,E8,DC"
""
@ -164,11 +184,21 @@
"Cart.Addresses" "C9,C8,C7"
""
"Cart.MD5" "87e79cd41ce136fd4f72cc6e2c161bee"
"Cart.Manufacturer" "Atari - GCC, Mark Ackerman, Glenn Parker"
"Cart.ModelNo" "CX2675"
"Cart.Name" "Ms. Pac-Man (1983) (Atari)"
"Display.Phosphor" "YES"
"Cart.Variations" "4"
"Cart.Formats" "6,0,B,0,B,1,_,D,1,VARS_VALID_AT_GAME_OVER;_CHERRIES_=_VAR_#4"
"Cart.Addresses" "FA,F9,F8,F7,0"
""
"Cart.MD5" "91c2098e88a6b13f977af8c003e0bca5"
"Cart.Manufacturer" "Atari - GCC"
"Cart.ModelNo" "CX2676"
"Cart.Name" "Centipede (1983) (Atari)"
"Cart.Formats" "6"
"Cart.Formats" "6,0,B,0,B,0,_,B,0,VARIATIONS_CANNOT_BE_DEFINED"
"Cart.Addresses" "F4,F5,F6"
""
@ -180,6 +210,14 @@
"Cart.Addresses" "D4,D3,E5"
""
"Cart.MD5" "94b92a882f6dbaa6993a46e2dcc58402"
"Cart.Manufacturer" "Activision, Larry Miller"
"Cart.ModelNo" "AX-026, AX-026-04"
"Cart.Name" "Enduro (1983) (Activision)"
"Cart.Formats" "6,0,B,0,B,0,DAY"
"Cart.Addresses" "AA,A9,A8,0,AD"
""
"Cart.MD5" "9ad36e699ef6f45d9eb6c4cf90475c9f"
"Cart.Manufacturer" "Imagic, Dennis Koble"
"Cart.ModelNo" "720103-1A, 720103-1B, IA3203, IX-010-04"
@ -206,8 +244,8 @@
"Cart.Name" "Decathlon (1983) (Activision)"
"Cart.Rarity" "Rare"
"Cart.Variations" "10"
"Cart.Formats" "4,0,B,0,D,1"
"Cart.Addresses" "95,96,80"
"Cart.Formats" "4,0,B,0,D,1,_,B,0,DECATHLON_&_100M_DASH_SHARE_VARIATION_1"
"Cart.Addresses" "95,96,80,0"
""
"Cart.MD5" "be929419902e21bd7830a7a7d746195d"
@ -233,7 +271,7 @@
"Cart.Name" "Yars' Revenge (1982) (Atari)"
"Display.Phosphor" "YES"
"Cart.Variations" "8"
"Cart.Formats" "6,0,B,0,B,1"
"Cart.Formats" "6,0,B,0,B,1,_,B,0,VARIATIONS_ARE_LARGER_BY_1"
"Cart.Addresses" "E0,E1,E2,80"
""
@ -241,7 +279,7 @@
"Cart.Manufacturer" "Atari - GCC, Dave Payne"
"Cart.ModelNo" "CX2669"
"Cart.Name" "Vanguard (1983) (Atari)"
"Cart.Formats" "6"
"Cart.Formats" "6,0,B,0,B,0,_,B,0,SCORE_IS_FOR_CURRENT_PLAYER"
"Cart.Addresses" "99,98,97"
""
@ -252,8 +290,18 @@
"Cart.Rarity" "Common"
"Display.Phosphor" "YES"
"Cart.Variations" "66"
"Cart.Formats" "5,1,0,B,D,0"
"Cart.Addresses" "BD,BE,80,C7"
"Cart.Formats" "5,1,H,1,D,0,_,B,0,VARIATIONS_>_32_DIFFER_BY_1"
"Cart.Addresses" "BD,BE,80"
""
"Cart.MD5" "d69559f9c9dc6ef528d841bf9d91b275"
"Cart.Manufacturer" "Activision, Alan Miller"
"Cart.ModelNo" "AX-016"
"Cart.Name" "StarMaster (1982) (Activision)"
"Cart.Note" "Use Color/BW switch to change between galactic chart and front views"
"Cart.Variations" "4"
"Cart.Formats" "4,0,B,0,B,1,_,B,0,SCORE_ONLY_CALCULATED_WHEN_GAME_IS_OVER"
"Cart.Addresses" "C1,C2,80"
""
"Cart.MD5" "dd7884b4f93cab423ac471aa1935e3df"
@ -261,15 +309,15 @@
"Cart.ModelNo" "CX2649, 49-75163"
"Cart.Name" "Asteroids (1981) (Atari)"
"Cart.Variations" "66"
"Cart.Formats" "5,1,0,B,D,0"
"Cart.Addresses" "BD,BE,80,C7"
"Cart.Formats" "5,1,H,1,D,0,_,B,0,VARIATIONS_>_32_DIFFER_BY_1"
"Cart.Addresses" "BD,BE,80"
""
"Cart.MD5" "dde55d9868911407fe8b3fefef396f00"
"Cart.Name" "Seawolf (2004) (Xype, Manuel Rotschkar)"
"Cart.Variations" "4"
"Cart.Formats" "6"
"Cart.Addresses" "90,91,92,0"
"Cart.Formats" "6,0,B,0,B,0,_,B,0,USER_DEFINED_VARIATION_BASED_ON_SWITCHES"
"Cart.Addresses" "90,91,92,0,0"
""
"Cart.MD5" "f0e0addc07971561ab80d9abe1b8d333"
@ -301,7 +349,7 @@
"Cart.Name" "Breakout (1978) (Atari)"
"Cart.Note" "Uses the Paddle Controllers"
"Controller.MouseAxis" "01 60"
"Cart.Formats" "3"
"Cart.Formats" "3,0,B,0,B,0,_,B,0,VARIATIONS_CANNOT_BE_DEFINED"
"Cart.Addresses" "CE,CD"
""

View File

@ -444,8 +444,9 @@ void GameInfoDialog::addHighScoresTab()
EditableWidget::TextFilter fVars = [](char c) {
return (c >= '0' && c <= '9');
};
EditableWidget::TextFilter fSpecial = [](char c) {
return (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || c == '.'|| c == '-';
EditableWidget::TextFilter fText = [](char c) {
return (c >= 'a' && c <= 'z') || (c >= ' ' && c < ',') || (c > ',' && c < '@');
};
xpos = HBORDER; ypos = VBORDER;
@ -499,7 +500,7 @@ void GameInfoDialog::addHighScoresTab()
xpos += 20; ypos += lineHeight + VGAP;
vwidth = _font.getStringWidth("AB") + 4;
vwidth = _font.getStringWidth("AB") + 3;
items.clear();
for (int i = 1; i <= HSM::MAX_SCORE_DIGITS; ++i)
VarList::push_back(items, std::to_string(i), std::to_string(i));
@ -553,13 +554,13 @@ void GameInfoDialog::addHighScoresTab()
myCurrentScore = new StaticTextWidget(myTab, _font, myCurrentScoreLabel->getRight(), ypos + 1,
"12345678");
xpos -= 20; ypos += lineHeight + VGAP * 4;
xpos -= 20; ypos += lineHeight + VGAP * 3;
vwidth = _font.getStringWidth("123") + 4;
mySpecialLabel = new StaticTextWidget(myTab, _font, xpos, ypos + 1, "Special");
mySpecialName = new EditTextWidget(myTab, _font, mySpecialLabel->getRight() + 19, ypos - 1,
swidth, lineHeight);
mySpecialName->setTextFilter(fSpecial);
mySpecialName->setTextFilter(fText);
wid.push_back(mySpecialName);
mySpecialAddressLabel = new StaticTextWidget(myTab, _font, myVarAddressLabel->getLeft(),
@ -580,6 +581,14 @@ void GameInfoDialog::addHighScoresTab()
"0-based", kHiScoresChanged);
wid.push_back(mySpecialZeroBased);
ypos += lineHeight + VGAP * 3;
myHighScoreNotesLabel = new StaticTextWidget(myTab, _font, xpos, ypos + 1, "Notes");
myHighScoreNotes = new EditTextWidget(myTab, _font, mySpecialName->getLeft(), ypos - 1,
_w - HBORDER - mySpecialName->getLeft() - 2 , lineHeight);
myHighScoreNotes->setTextFilter(fText);
wid.push_back(myHighScoreNotes);
// Add items for tab 4
addToFocusList(wid, myTab, tabID);
}
@ -785,6 +794,8 @@ void GameInfoDialog::loadHighScoresProperties(const Properties& props)
mySpecialBCD->setState(info.specialBCD);
mySpecialZeroBased->setState(info.specialZeroBased);
myHighScoreNotes->setText(info.notes);
ss.str("");
ss << hex << right //<< setw(HSM::MAX_ADDR_CHARS) << setfill(' ')
<< uppercase << info.varsAddr;
@ -898,15 +909,17 @@ void GameInfoDialog::saveHighScoresProperties()
info.varsZeroBased = myVarsZeroBased->getState();
info.varsBCD = myVarsBCD->getState();
info.special = mySpecialName->getText();
info.specialZeroBased = mySpecialZeroBased->getState();
info.specialBCD = mySpecialBCD->getState();
info.numDigits = myScoreDigits->getSelected() + 1;
info.trailingZeroes = myTrailingZeroes->getSelected();
info.scoreBCD = myScoreBCD->getState();
info.scoreInvert = myScoreInvert->getState();
info.special = mySpecialName->getText();
info.specialZeroBased = mySpecialZeroBased->getState();
info.specialBCD = mySpecialBCD->getState();
info.notes = myHighScoreNotes->getText();
// fill addresses
string strAddr;
@ -1097,16 +1110,6 @@ void GameInfoDialog::updateHighScoresWidgets()
myVarsBCD->setEnabled(enableVars && stringToInt(myVariations->getText(), 1) >= 10);
myVarsZeroBased->setEnabled(enableVars);
mySpecialLabel->setEnabled(enable);
mySpecialName->setEnabled(enable);
mySpecialName->setEditable(enable);
mySpecialAddressLabel->setEnabled(enableSpecial);
mySpecialAddress->setEnabled(enableSpecial);
mySpecialAddress->setEditable(enableSpecial);
mySpecialAddressVal->setEnabled(enableSpecial && enableConsole);
mySpecialBCD->setEnabled(enableSpecial);
mySpecialZeroBased->setEnabled(enableSpecial);
myScoreLabel->setEnabled(enable);
myScoreDigitsLabel->setEnabled(enable);
myScoreDigits->setEnabled(enable);
@ -1126,6 +1129,19 @@ void GameInfoDialog::updateHighScoresWidgets()
myCurrentScoreLabel->setEnabled(enable && enableConsole);
myCurrentScore->setEnabled(enable && enableConsole);
mySpecialLabel->setEnabled(enable);
mySpecialName->setEnabled(enable);
mySpecialName->setEditable(enable);
mySpecialAddressLabel->setEnabled(enableSpecial);
mySpecialAddress->setEnabled(enableSpecial);
mySpecialAddress->setEditable(enableSpecial);
mySpecialAddressVal->setEnabled(enableSpecial && enableConsole);
mySpecialBCD->setEnabled(enableSpecial);
mySpecialZeroBased->setEnabled(enableSpecial);
myHighScoreNotesLabel->setEnabled(enable);
myHighScoreNotes->setEnabled(enable);
// verify and update widget data
// update variations RAM value

View File

@ -132,14 +132,6 @@ class GameInfoDialog : public Dialog, public CommandSender
CheckboxWidget* myVarsBCD{nullptr};
CheckboxWidget* myVarsZeroBased{nullptr};
StaticTextWidget* mySpecialLabel{nullptr};
EditTextWidget* mySpecialName{nullptr};
StaticTextWidget* mySpecialAddressLabel{nullptr};
EditTextWidget* mySpecialAddress{nullptr};
EditTextWidget* mySpecialAddressVal{nullptr};
CheckboxWidget* mySpecialBCD{nullptr};
CheckboxWidget* mySpecialZeroBased{nullptr};
StaticTextWidget* myScoreLabel{nullptr};
StaticTextWidget* myScoreDigitsLabel{nullptr};
PopUpWidget* myScoreDigits{nullptr};
@ -154,6 +146,17 @@ class GameInfoDialog : public Dialog, public CommandSender
StaticTextWidget* myCurrentScoreLabel{nullptr};
StaticTextWidget* myCurrentScore{nullptr};
StaticTextWidget* mySpecialLabel{nullptr};
EditTextWidget* mySpecialName{nullptr};
StaticTextWidget* mySpecialAddressLabel{nullptr};
EditTextWidget* mySpecialAddress{nullptr};
EditTextWidget* mySpecialAddressVal{nullptr};
CheckboxWidget* mySpecialBCD{nullptr};
CheckboxWidget* mySpecialZeroBased{nullptr};
StaticTextWidget* myHighScoreNotesLabel{nullptr};
EditTextWidget* myHighScoreNotes{nullptr};
enum {
kVCenterChanged = 'Vcch',
kPhosphorChanged = 'PPch',

View File

@ -72,7 +72,8 @@ HighScoresDialog::HighScoresDialog(OSystem& osystem, DialogContainer& parent,
{
const GUI::Font& ifont = instance().frameBuffer().infoFont();
const int lineHeight = _font.getLineHeight(),
fontWidth = _font.getMaxCharWidth();
fontWidth = _font.getMaxCharWidth(),
infoLineHeight = ifont.getLineHeight();
const int VBORDER = 10;
const int HBORDER = 10;
const int VGAP = 4;
@ -135,12 +136,17 @@ HighScoresDialog::HighScoresDialog(OSystem& osystem, DialogContainer& parent,
ypos += lineHeight + VGAP;
}
ypos += VGAP * 2;
ypos += VGAP;
myMD5Widget = new StaticTextWidget(this, ifont, xpos, ypos + 1, "MD5: 12345678901234567890123456789012");
_w = myDeleteButtons[0]->getRight() + HBORDER;
myNotesWidget = new StaticTextWidget(this, ifont, xpos, ypos + 1, _w - HBORDER * 2,
infoLineHeight, "Note: ");
ypos += infoLineHeight + VGAP;
myMD5Widget = new StaticTextWidget(this, ifont, xpos, ypos + 1, "MD5: 12345678901234567890123456789012");
_h = myMD5Widget->getBottom() + VBORDER + buttonHeight(_font) + VBORDER;
_w = myDeleteButtons[0]->getRight() + HBORDER;
myGameNameWidget = new StaticTextWidget(this, _font, HBORDER, VBORDER + _th + 1,
_w - HBORDER * 2, lineHeight);
@ -201,12 +207,14 @@ void HighScoresDialog::loadConfig()
label = label.substr(label.length() - 5);
mySpecialLabelWidget->setLabel(label);
myNotesWidget->setLabel("Note: " + instance().highScores().notes());
if (instance().hasConsole())
myMD5 = instance().console().properties().get(PropType::Cart_MD5);
else
myMD5 = instance().launcher().selectedRomMD5();
myMD5Widget->setLabel("MD5: " + myMD5);
myMD5Widget->setLabel("MD5: " + myMD5);
// requires the current MD5
myGameNameWidget->setLabel(cartName());

View File

@ -129,6 +129,7 @@ class HighScoresDialog : public Dialog
StaticTextWidget* myDateWidgets[NUM_RANKS]{nullptr};
ButtonWidget* myDeleteButtons[NUM_RANKS]{nullptr};
StaticTextWidget* myNotesWidget{nullptr};
StaticTextWidget* myMD5Widget{nullptr};
Menu::AppMode myMode{Menu::AppMode::emulator};