Skip to content

Commit cf68fd5

Browse files
committed
Revert "Update hiscore.rst with plugin configuration details (#14403)"
Revert "Implement game exclusion support for hiscore (#14375)" This reverts commit 0eb42bd. This reverts commit 7eba3bd. There's too much wrong with this in terms of design and implementation. It isn't releasable.
1 parent 05c5c7e commit cf68fd5

File tree

2 files changed

+17
-123
lines changed

2 files changed

+17
-123
lines changed

docs/source/plugins/hiscore.rst

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,3 @@ name corresponding the system short name (or ROM set name) with the extension
2626
file **mooncrst.hi** in the **hiscore** folder in your plugin data folder. The
2727
settings for the hiscore support plugin are stored in the file **plugin.cfg** in
2828
the **hiscore** folder in the plugin data folder (this file is in JSON format).
29-
30-
The hiscore support plugin can be disabled on a game-by-game basis by toggling the
31-
**Enable Hiscore Support for this game** option within the plugin's menu. By
32-
default, the plugin is enabled for all games. Games that have been excluded are
33-
tracked in a json file **exclude_games.json** that is stored in the
34-
**plugins/hiscore** folder.

plugins/hiscore/init.lua

Lines changed: 17 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
1-
-- hiscore.lua with exclusion support
1+
-- hiscore.lua
2+
-- by [email protected], CC0 license
3+
--
24
-- This uses MAME's built-in Lua scripting to implement
35
-- high-score saving with hiscore.dat infom just as older
46
-- builds did in the past.
57
--
6-
-- original by [email protected], CC0 license
7-
-- updated by [email protected] to enable/disable hiscore support per game
8-
--
9-
local json = require('json')
10-
local lfs = require('lfs')
11-
128
local exports = {
139
name = 'hiscore',
14-
version = '1.1.0',
15-
description = 'Hiscore with per-game exclusion support',
10+
version = '1.0.1',
11+
description = 'Hiscore',
1612
license = 'CC0',
17-
author = { name = '[email protected] + [email protected]' }
18-
}
13+
author = { name = '[email protected]' } }
1914

2015
local hiscore = exports
2116

@@ -26,53 +21,6 @@ function hiscore.set_folder(path)
2621
hiscore_plugin_path = path
2722
end
2823

29-
-- added function to save/update list of excluded games (hiscore support disabled)
30-
local excluded_games = {}
31-
32-
local function save_exclusions()
33-
if not hiscore_plugin_path then return end
34-
local exclude_file = hiscore_plugin_path .. '/exclude_games.json'
35-
local file = io.open(exclude_file, 'w')
36-
if file then
37-
local data = { excluded_games = {} }
38-
for game, _ in pairs(excluded_games) do
39-
table.insert(data.excluded_games, game)
40-
end
41-
file:write(json.stringify(data, { indent = true }))
42-
file:close()
43-
emu.print_verbose('[Hiscore] Exclusions saved.')
44-
else
45-
emu.print_error('[Hiscore] Failed to save exclusions.')
46-
end
47-
end
48-
49-
-- added function to load list of excluded games (hiscore support disabled)
50-
local function load_exclusions()
51-
if not hiscore_plugin_path then return end
52-
local exclude_file = hiscore_plugin_path .. '/exclude_games.json'
53-
local file = io.open(exclude_file, 'r')
54-
if file then
55-
local content = file:read('*all')
56-
file:close()
57-
local data = json.decode(content)
58-
if data and data.excluded_games then
59-
for _, game in ipairs(data.excluded_games) do
60-
excluded_games[game] = true
61-
end
62-
emu.print_verbose('[Hiscore] Exclusions loaded.')
63-
end
64-
else
65-
emu.print_verbose('[Hiscore] No exclude_games.json found. No exclusions active.')
66-
end
67-
end
68-
69-
-- added function to determine if active game is on the exclusion list (hiscore support disabled)
70-
local function is_game_excluded()
71-
local game = emu.romname()
72-
return excluded_games[game] == true
73-
end
74-
75-
7624
function hiscore.startplugin()
7725

7826
local function get_data_path()
@@ -134,59 +82,26 @@ function hiscore.startplugin()
13482

13583
-- build menu
13684
local function populate_menu()
137-
local items = {}
138-
139-
table.insert(items, { _p('plugin-hiscore', 'Hiscore Support Options'), '', 'off' })
140-
table.insert(items, { '---', '', '' })
141-
142-
local game = emu.romname()
143-
local enabled = not is_game_excluded()
144-
local status = enabled and 'Yes' or 'No'
145-
table.insert(items, { "Enable Hiscore Support for this game", status, enabled and 'l' or 'r' })
146-
147-
local setting = timed_save and _p('plugin-hiscore', 'When updated') or _p('plugin-hiscore', 'On exit')
148-
table.insert(items, { _p('plugin-hiscore', 'Save scores'), setting, timed_save and 'l' or 'r' })
149-
150-
return items
85+
local items = { }
86+
local setting = timed_save and _p('plugin-hiscore', 'When updated') or _p('plugin-hiscore', 'On exit')
87+
table.insert(items, { _p('plugin-hiscore', 'Hiscore Support Options'), '', 'off' })
88+
table.insert(items, { '---', '', '' })
89+
table.insert(items, { _p('plugin-hiscore', 'Save scores'), setting, timed_save and 'l' or 'r' })
90+
return items
15191
end
15292

15393
-- handle menu events
15494
local function handle_menu(index, event)
155-
156-
-- added menu item to enable/disable hiscore support for this game
157-
if index == 3 then
158-
if event == 'left' or event == 'right' then
159-
local game = emu.romname()
160-
if event == 'left' then
161-
-- Disable Hiscore Support for this game (add to exclude list)
162-
excluded_games[game] = true
163-
emu.print_verbose(string.format('[Hiscore] Hiscore support disabled for game "%s"', game))
164-
elseif event == 'right' then
165-
-- Enable Hiscore Support for this game (remove from exclude list)
166-
excluded_games[game] = nil
167-
emu.print_verbose(string.format('[Hiscore] Hiscore support enabled for game "%s"', game))
168-
end
169-
save_exclusions()
170-
return true
171-
else
172-
return false
173-
end
174-
end
175-
176-
-- previous menu item to select when scores are saved remains unchanged (now on menu index #4)
177-
if index == 4 then
17895
if event == 'left' then
179-
timed_save = false
180-
return true
96+
timed_save = false
97+
return true
18198
elseif event == 'right' then
182-
timed_save = true
183-
return true
99+
timed_save = true
100+
return true
184101
end
185-
end
186-
return false
102+
return false
187103
end
188104

189-
190105
local hiscoredata_path = "hiscore.dat";
191106

192107
local current_checksum = 0;
@@ -305,12 +220,6 @@ function hiscore.startplugin()
305220

306221

307222
local function write_scores ( posdata )
308-
-- check if game is on the exclude list before writing
309-
if is_game_excluded() then
310-
emu.print_verbose('[Hiscore] Skipping write_scores - excluded game: ' .. emu.romname())
311-
return
312-
end
313-
314223
emu.print_verbose("hiscore: write_scores")
315224
local output = io.open(get_file_name(), "wb");
316225
if not output then
@@ -334,12 +243,6 @@ function hiscore.startplugin()
334243

335244

336245
local function read_scores ( posdata )
337-
-- check if game is on the exclude list before loading scores
338-
if is_game_excluded() then
339-
emu.print_verbose('[Hiscore] Skipping read_scores - excluded game: ' .. emu.romname())
340-
return false
341-
end
342-
343246
local input = io.open(get_file_name(), "rb");
344247
if input then
345248
for ri,row in ipairs(posdata) do
@@ -433,9 +336,6 @@ function hiscore.startplugin()
433336
last_write_time = -10
434337
emu.print_verbose("Starting " .. emu.gamename())
435338
read_config();
436-
437-
-- re-load game exclusions list on reset
438-
load_exclusions();
439339
local dat = read_hiscore_dat()
440340
if dat and dat ~= "" then
441341
emu.print_verbose( "hiscore: found hiscore.dat entry for " .. emu.romname() );

0 commit comments

Comments
 (0)