Skip to content

Commit

Permalink
Merge pull request #49 from burninrubber0/language-update
Browse files Browse the repository at this point in the history
Language editor fixes
  • Loading branch information
burninrubber0 authored Dec 7, 2023
2 parents 9c4571c + c8d7811 commit 9e4d85f
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 9 deletions.
26 changes: 18 additions & 8 deletions LangEditor/LangEdit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,25 +113,32 @@ public void UpdateDisplay()
MessageBoxButtons.OK);
}

public void RebuildLanguage()
public int RebuildLanguage()
{
if (_ignoreChanges)
return;
return 1;

Dictionary<uint, string> data = new Dictionary<uint, string>();

for (int i = 0; i < dgvMain.Rows.Count - 1; ++i)
{
string idString = (string)dgvMain.Rows[i].Cells[0].Value;

if (idString == null)
{
MessageBox.Show(this, "ID cannot be left blank", "Warning",
MessageBoxButtons.OK, MessageBoxIcon.Warning);
return 2;
}

uint id;
if (idString.StartsWith("0x") && idString.Length == 10) // Hash
{
if (!uint.TryParse(idString[2..], NumberStyles.AllowHexSpecifier, CultureInfo.CurrentCulture, out id))
{
MessageBox.Show(this, "Failed to parse ID \"" + idString + "\"", "Warning",
MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
return 3;
}
}
else // String
Expand All @@ -144,14 +151,16 @@ public void RebuildLanguage()
{
MessageBox.Show(this, "ID " + idString + " already in use", "Warning",
MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
return 4;
}
data.Add(id, value);
}

_lang.mpEntries = data;

Changed?.Invoke();

return 0;
}

private void importToolStripMenuItem_Click(object sender, EventArgs e)
Expand Down Expand Up @@ -232,9 +241,10 @@ private void exportToolStripMenuItem_Click(object sender, EventArgs e)

private void applyChangesToolStripMenuItem_Click(object sender, EventArgs e)
{
RebuildLanguage();
int result = RebuildLanguage();

MessageBox.Show(this, "Done!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
if (result == 0)
MessageBox.Show(this, "Done!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
}

private void findToolStripMenuItem_Click(object sender, EventArgs e)
Expand All @@ -247,8 +257,8 @@ private void findToolStripMenuItem_Click(object sender, EventArgs e)

foreach (DataGridViewRow row in dgvMain.Rows)
{
if (((string)row.Cells[0].Value).Contains(value, StringComparison.CurrentCultureIgnoreCase)
|| ((string)row.Cells[1].Value).Contains(value, StringComparison.CurrentCultureIgnoreCase))
if ((row.Cells[0].Value != null && ((string)row.Cells[0].Value).Contains(value, StringComparison.CurrentCultureIgnoreCase))
|| (row.Cells[1].Value != null && ((string)row.Cells[1].Value).Contains(value, StringComparison.CurrentCultureIgnoreCase)))
{
dgvMain.ClearSelection();
dgvMain.CurrentCell = row.Cells[0];
Expand Down
3 changes: 2 additions & 1 deletion LangEditor/Language.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ public bool Write(BundleEntry entry)
bw.Write((uint)ms.Length); // String pointer
lastPos = ms.Position;
ms.Position = ms.Length;
bw.Write(langEntry.Value.ToCharArray()); // String data
if (langEntry.Value != null)
bw.Write(langEntry.Value.ToCharArray()); // String data
bw.Write((byte)0); // Null terminator
ms.Position = lastPos;
}
Expand Down
63 changes: 63 additions & 0 deletions LangEditor/keys/unsorted.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,18 @@ ACH_40X_MULTIPLIER_NAME
ACH_500_TAKEDOWNS_DESC
ACH_500_TAKEDOWNS_HOWTO
ACH_500_TAKEDOWNS_NAME
ACH_50_CAM_SHOTS_DESC
ACH_50_CAM_SHOTS_HOWTO
ACH_50_CAM_SHOTS_NAME
ACH_50_RIVALS_DESC
ACH_50_RIVALS_HOWTO
ACH_50_RIVALS_NAME
ACH_50_SNAPSHOTS_DESC
ACH_50_SNAPSHOTS_HOWTO
ACH_50_SNAPSHOTS_NAME
ACH_5_CAM_SHOTS_DESC
ACH_5_CAM_SHOTS_HOWTO
ACH_5_CAM_SHOTS_NAME
ACH_ALL_CAR_CHALLENGES_DESC
ACH_ALL_CAR_CHALLENGES_HOWTO
ACH_ALL_CAR_CHALLENGES_NAME
Expand Down Expand Up @@ -100,6 +106,15 @@ ACH_COLLECT_5_STUNTS_NAME
ACH_COLLECT_60_STUNTS_DESC
ACH_COLLECT_60_STUNTS_HOWTO
ACH_COLLECT_60_STUNTS_NAME
ACH_COLLECT_X_JUMPS_DESC
ACH_COLLECT_X_JUMPS_HOWTO
ACH_COLLECT_X_JUMPS_NAME
ACH_COLLECT_X_SMASHES_DESC
ACH_COLLECT_X_SMASHES_HOWTO
ACH_COLLECT_X_SMASHES_NAME
ACH_COLLECT_X_STUNTS_DESC
ACH_COLLECT_X_STUNTS_HOWTO
ACH_COLLECT_X_STUNTS_NAME
ACH_COMPLETE_ALL_DAY_ROAD_RULES_DESC
ACH_COMPLETE_ALL_DAY_ROAD_RULES_HOWTO
ACH_COMPLETE_ALL_DAY_ROAD_RULES_NAME
Expand Down Expand Up @@ -139,6 +154,9 @@ ACH_FIRST_NIGHT_ROAD_RULE_NAME
ACH_FIRST_REPAIR_DESC
ACH_FIRST_REPAIR_HOWTO
ACH_FIRST_REPAIR_NAME
ACH_FIRST_RIVAL_DESC
ACH_FIRST_RIVAL_HOWTO
ACH_FIRST_RIVAL_NAME
ACH_FLATSPIN_DESC
ACH_FLATSPIN_HOWTO
ACH_FLATSPIN_NAME
Expand Down Expand Up @@ -190,6 +208,9 @@ ACH_MILLIONAIRES_NAME
ACH_MONSTER_ROAD_RULE_TIME_DESC
ACH_MONSTER_ROAD_RULE_TIME_HOWTO
ACH_MONSTER_ROAD_RULE_TIME_NAME
ACH_ONLINE_RACE_DESC
ACH_ONLINE_RACE_HOWTO
ACH_ONLINE_RACE_NAME
ACH_POWER_PARK_80_DESC
ACH_POWER_PARK_80_HOWTO
ACH_POWER_PARK_80_NAME
Expand All @@ -214,6 +235,9 @@ ACH_SHORT_WHEELIE_NAME
ACH_SHOWTIME_5X_MULTIPLIER_DESC
ACH_SHOWTIME_5X_MULTIPLIER_HOWTO
ACH_SHOWTIME_5X_MULTIPLIER_NAME
ACH_SHOWTIME_MULTIPLIER_DESC
ACH_SHOWTIME_MULTIPLIER_HOWTO
ACH_SHOWTIME_MULTIPLIER_NAME
ACH_SHUTDOWN_HUNTER_DESC
ACH_SHUTDOWN_HUNTER_HOWTO
ACH_SHUTDOWN_HUNTER_NAME
Expand Down Expand Up @@ -244,6 +268,9 @@ ACH_WIN_10_RACES_NAME
ACH_WIN_10_XS_CARS_DESC
ACH_WIN_10_XS_CARS_HOWTO
ACH_WIN_10_XS_CARS_NAME
ACH_WIN_20_XS_CARS_DESC
ACH_WIN_20_XS_CARS_HOWTO
ACH_WIN_20_XS_CARS_NAME
ACH_WIN_25_XS_CARS_DESC
ACH_WIN_25_XS_CARS_HOWTO
ACH_WIN_25_XS_CARS_NAME
Expand All @@ -253,6 +280,12 @@ ACH_WIN_7_STUNT_RUNS_NAME
ACH_WIN_8P_RACE_DESC
ACH_WIN_8P_RACE_HOWTO
ACH_WIN_8P_RACE_NAME
ACH_WIN_ALL_DAY_BURNING_ROUTES_DESC
ACH_WIN_ALL_DAY_BURNING_ROUTES_HOWTO
ACH_WIN_ALL_DAY_BURNING_ROUTES_NAME
ACH_WIN_ALL_NIGHT_BURNING_ROUTES_DESC
ACH_WIN_ALL_NIGHT_BURNING_ROUTES_HOWTO
ACH_WIN_ALL_NIGHT_BURNING_ROUTES_NAME
ACH_WIN_DAY_BURNING_ROUTES_DESC
ACH_WIN_DAY_BURNING_ROUTES_HOWTO
ACH_WIN_DAY_BURNING_ROUTES_NAME
Expand Down Expand Up @@ -321,6 +354,7 @@ ADV_CONTROL_OPTION_FFB_NONE
AHEAD_IN_X
AIR
ALL_DRIVE_THRUS_OF_TYPE_FOUND
ALL_VEHICLES_TITLE
BARRELROLL
BARRELROLL_X
BESTOFREST_CONTINUE
Expand Down Expand Up @@ -365,6 +399,7 @@ BRH_SL
BRH_WM
BRIGHTNESS
BROUGHT_TO_YOU_BY
BURNING_RIDES_COMPLETE
BURNING_RIDES_DAY
BURNING_RIDES_NIGHT
BURNOUT_PLAYER_LIST_WOW
Expand Down Expand Up @@ -465,7 +500,9 @@ CAPS_BUTTON_BUYNOW
CAPS_BUTTON_CANCEL
CAPS_BUTTON_CCANCELC
CAPS_BUTTON_CHANGE_A
CAPS_BUTTON_CHANGE_CAR
CAPS_BUTTON_CHANGE_ORDER
CAPS_BUTTON_CHANGE_ROUTE
CAPS_BUTTON_CONFIRM
CAPS_BUTTON_CONTINUE
CAPS_BUTTON_DELETE
Expand Down Expand Up @@ -520,7 +557,10 @@ CAPS_STORE_BACK
CAPS_TRAX_MODE
CAPTURED
CAPTURED_FOR
CAPTURED_FROM
CAPTURING_FREEBURN_MUGSHOT
CAPTURING_IMAGE
CAPTURING_PAYBACK_SMUGSHOT
CAPTURING_SMUGSHOT
CARS_OWNED
CARS_TO_SHUTDOWN
Expand Down Expand Up @@ -659,6 +699,7 @@ CN_TITLE_CREDITS
CN_TITLE_DRIVERDETAILS
CN_TITLE_EATRAX
CN_TITLE_EDIT_ROUTE
CN_TITLE_FREEBURN
CN_TITLE_FRIENDS
CN_TITLE_ISLANDINFO
CN_TITLE_LINEUP
Expand All @@ -680,6 +721,7 @@ CN_TITLE_OPT_SCREENS
CN_TITLE_OPT_VIDEO
CN_TITLE_PLAYERS
CN_TITLE_PROFILE
CN_TITLE_PROGRESS
CN_TITLE_QUICK_MATCH
CN_TITLE_RIDERDETAILS
CN_TITLE_SELECT_ROUTE
Expand Down Expand Up @@ -745,6 +787,7 @@ CONTROL_OPTION_CONTROLLER_LIST
CONTROL_OPTION_REBIND_PROMPT
CONT_OPT_BM_FAILED
CONT_OPT_BM_WARNING
COPSNISLAND_TITLE
COPSNROBBERSROOT_BLURB_LONG
COPSNROBBERSROOT_BLURB_SHORT
COPSNROBBERSROOT_TITLE
Expand Down Expand Up @@ -921,6 +964,7 @@ GENERAL_DECIMAL_SEPARATOR
GENERAL_OPTION_ACCEPT
GENERAL_OPTION_BACK
GENERAL_OPTION_BUTTON_BACKTOGAME
GENERAL_OPTION_BUTTON_CANCEL
GENERAL_OPTION_BUTTON_EMAIL
GENERAL_OPTION_BUTTON_MORE_INFO
GENERAL_OPTION_BUTTON_NO_CONTINUE
Expand Down Expand Up @@ -1119,6 +1163,7 @@ HUDMESSAGE_ONLINE_LAST_PLACE
HUDMESSAGE_ONLINE_ON_TAIL
HUDMESSAGE_ONLINE_TAKES_DOWN
HUDMESSAGE_ONLINE_TAKES_LEAD
HUDMESSAGE_ONL_FBURN_X_CALLS_RACE
HUDMESSAGE_ONL_FBURN_X_JOINS
HUDMESSAGE_ONL_FBURN_X_LEAVES
HUDMESSAGE_ON_PLAYER
Expand Down Expand Up @@ -1216,6 +1261,13 @@ HUDMESSAGE_SKILLZ_X_GOT_TAKEDOWN
HUDMESSAGE_SKILLZ_X_GOT_TIME_IN_AIR
HUDMESSAGE_SKILLZ_X_GOT_TRAF
HUDMESSAGE_SKILLZ_X_GOT_WHEELIE
HUDMESSAGE_SKILLZ_YOU_GOT_BOOST_CHAIN
HUDMESSAGE_SKILLZ_YOU_GOT_DRIFT
HUDMESSAGE_SKILLZ_YOU_GOT_NEAR_MISS
HUDMESSAGE_SKILLZ_YOU_GOT_ONCOMING
HUDMESSAGE_SKILLZ_YOU_GOT_TAKEDOWN
HUDMESSAGE_SKILLZ_YOU_GOT_TIME_IN_AIR
HUDMESSAGE_SKILLZ_YOU_GOT_WHEELIE
HUDMESSAGE_SMASH
HUDMESSAGE_SMASHES_COMPLETE
HUDMESSAGE_SMASH_ISLAND
Expand Down Expand Up @@ -1291,6 +1343,7 @@ HUD_INFO_TARGET_RUN
HUD_INFO_TDTARGET
HUD_INFO_TIME
HUD_INFO_TIMED_CHALLENGE
HUD_INFO_TO
HUD_LEFT_INITIAL
HUD_NOCRASH
HUD_NOTIME
Expand Down Expand Up @@ -1372,6 +1425,8 @@ ISLAND_EVENTS_FOUND
ISLAND_INFO
ISLAND_RECORD_TITLE_BEST_BOOSTCHAIN
ISLAND_RECORD_TITLE_BEST_POWER_PARKING
ISLAND_RECORD_TITLE_BEST_ROADRAGE
ISLAND_RECORD_TITLE_BEST_SHOWTIME
ISLAND_RECORD_TITLE_BEST_STUNTRUN
ISLAND_RECORD_TITLE_BIGGEST_FLATSPIN
ISLAND_RECORD_TITLE_BILLBOARDS
Expand Down Expand Up @@ -1402,6 +1457,7 @@ KEEP_TRYING
KPC_EVENT_DRIVETHRUS_PLURAL
KPC_EVENT_DRIVETHRUS_PLURAL_ISLAND
KPC_EVENT_JUNCTIONS_ALL_BRN_ROUTE
KPC_EVENT_JUNCTIONS_ALL_MM
KPC_EVENT_JUNCTIONS_ALL_RACE
KPC_EVENT_JUNCTIONS_ALL_RR
KPC_EVENT_JUNCTIONS_ALL_STUNT
Expand Down Expand Up @@ -1581,6 +1637,7 @@ K_FBMG_HEIST_LOAD_GOLD
K_FBMG_HEIST_LOAD_ROBBER_DEST
K_FBMG_HEIST_LOAD_ROBBER_GET_GOLD
K_FBMG_HEIST_LOAD_TITLE
K_FBMG_HEIST_LOAD_YOU
K_FBMG_HEIST_LOAD_YOU_COPS
K_FBMG_HEIST_LOAD_YOU_ROBBER
K_FBMG_HEIST_LOSE_COPS
Expand Down Expand Up @@ -2154,6 +2211,7 @@ NUDGE
NUM_ROUNDS
OFFLINE_POPUP_RACE_SPLASH_TEXT
ONCOMING
ONLINE_ACCOUNT_DISABLED
ONLINE_ALREADY_SIGNED_IN
ONLINE_AWARD_LONGEST_DRIFT_OVERALL
ONLINE_AWARD_LONGEST_DRIFT_OVERALL_1
Expand Down Expand Up @@ -3311,6 +3369,7 @@ PP_TIME
PP_UNLUCKY
PP_WRONG_WAY
PP_X_POINTS
PP_YOUR_SCORE
PP_YOU_ARE_ALMOST_OUT_OF_TIME
PP_YOU_CRASHED
PP_YOU_STRAYED_TOO_FAR
Expand Down Expand Up @@ -3513,6 +3572,7 @@ SB_5P_CHALS
SB_6P_CHALS
SB_7P_CHALS
SB_8P_CHALS
SCOREBOARD_BIKE
SCOREBOARD_CAR
SCOREBOARD_COUNTRY
SCOREBOARD_EVENT
Expand Down Expand Up @@ -3824,6 +3884,9 @@ TOYCARSPACK1ROOT_TITLE
TOYCARSPACK2ROOT_BLURB_LONG
TOYCARSPACK2ROOT_BLURB_SHORT
TOYCARSPACK2ROOT_TITLE
TOY_4x4_CAR_BLURB_LONG
TOY_4x4_CAR_BLURB_SHORT
TOY_4x4_CAR_TITLE
TOY_BIKE_FIREHAWK_BLURB_LONG
TOY_BIKE_FIREHAWK_BLURB_SHORT
TOY_BIKE_FIREHAWK_TITLE
Expand Down

0 comments on commit 9e4d85f

Please sign in to comment.