summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2025-10-30 03:54:13 +1100
committer Vas Crabb <vas@vastheman.com>2025-10-30 03:57:18 +1100
commitcf68fd5e3efa33a3a39b660cd9c977e34a8c749b (patch)
treecae081a2765875c4edde72a556ed0a5a6098efda
parent05c5c7e4a31cf3c368fefc9296b4a1f8b1db0f0e (diff)
Revert "Update hiscore.rst with plugin configuration details (#14403)"
Revert "Implement game exclusion support for hiscore (#14375)" This reverts commit 0eb42bd963b350e96064423c8ee2b6cacc34fdef. This reverts commit 7eba3bd1b383d5500edc48d8e938020b9ba6853e. There's too much wrong with this in terms of design and implementation. It isn't releasable.
-rw-r--r--docs/source/plugins/hiscore.rst6
-rw-r--r--plugins/hiscore/init.lua134
2 files changed, 17 insertions, 123 deletions
diff --git a/docs/source/plugins/hiscore.rst b/docs/source/plugins/hiscore.rst
index ed96e2af508..389dea598ac 100644
--- a/docs/source/plugins/hiscore.rst
+++ b/docs/source/plugins/hiscore.rst
@@ -26,9 +26,3 @@ name corresponding the system short name (or ROM set name) with the extension
file **mooncrst.hi** in the **hiscore** folder in your plugin data folder. The
settings for the hiscore support plugin are stored in the file **plugin.cfg** in
the **hiscore** folder in the plugin data folder (this file is in JSON format).
-
-The hiscore support plugin can be disabled on a game-by-game basis by toggling the
-**Enable Hiscore Support for this game** option within the plugin's menu. By
-default, the plugin is enabled for all games. Games that have been excluded are
-tracked in a json file **exclude_games.json** that is stored in the
-**plugins/hiscore** folder.
diff --git a/plugins/hiscore/init.lua b/plugins/hiscore/init.lua
index 8284ec96644..8b8dd6c6d23 100644
--- a/plugins/hiscore/init.lua
+++ b/plugins/hiscore/init.lua
@@ -1,21 +1,16 @@
--- hiscore.lua with exclusion support
+-- hiscore.lua
+-- by borgar@borgar.net, CC0 license
+--
-- This uses MAME's built-in Lua scripting to implement
-- high-score saving with hiscore.dat infom just as older
-- builds did in the past.
--
--- original by borgar@borgar.net, CC0 license
--- updated by aaciii@yahoo.com to enable/disable hiscore support per game
---
-local json = require('json')
-local lfs = require('lfs')
-
local exports = {
name = 'hiscore',
- version = '1.1.0',
- description = 'Hiscore with per-game exclusion support',
+ version = '1.0.1',
+ description = 'Hiscore',
license = 'CC0',
- author = { name = 'borgar@borgar.net + aaciii@yahoo.com' }
-}
+ author = { name = 'borgar@borgar.net' } }
local hiscore = exports
@@ -26,53 +21,6 @@ function hiscore.set_folder(path)
hiscore_plugin_path = path
end
--- added function to save/update list of excluded games (hiscore support disabled)
-local excluded_games = {}
-
-local function save_exclusions()
- if not hiscore_plugin_path then return end
- local exclude_file = hiscore_plugin_path .. '/exclude_games.json'
- local file = io.open(exclude_file, 'w')
- if file then
- local data = { excluded_games = {} }
- for game, _ in pairs(excluded_games) do
- table.insert(data.excluded_games, game)
- end
- file:write(json.stringify(data, { indent = true }))
- file:close()
- emu.print_verbose('[Hiscore] Exclusions saved.')
- else
- emu.print_error('[Hiscore] Failed to save exclusions.')
- end
-end
-
--- added function to load list of excluded games (hiscore support disabled)
-local function load_exclusions()
- if not hiscore_plugin_path then return end
- local exclude_file = hiscore_plugin_path .. '/exclude_games.json'
- local file = io.open(exclude_file, 'r')
- if file then
- local content = file:read('*all')
- file:close()
- local data = json.decode(content)
- if data and data.excluded_games then
- for _, game in ipairs(data.excluded_games) do
- excluded_games[game] = true
- end
- emu.print_verbose('[Hiscore] Exclusions loaded.')
- end
- else
- emu.print_verbose('[Hiscore] No exclude_games.json found. No exclusions active.')
- end
-end
-
--- added function to determine if active game is on the exclusion list (hiscore support disabled)
-local function is_game_excluded()
- local game = emu.romname()
- return excluded_games[game] == true
-end
-
-
function hiscore.startplugin()
local function get_data_path()
@@ -134,59 +82,26 @@ function hiscore.startplugin()
-- build menu
local function populate_menu()
- local items = {}
-
- table.insert(items, { _p('plugin-hiscore', 'Hiscore Support Options'), '', 'off' })
- table.insert(items, { '---', '', '' })
-
- local game = emu.romname()
- local enabled = not is_game_excluded()
- local status = enabled and 'Yes' or 'No'
- table.insert(items, { "Enable Hiscore Support for this game", status, enabled and 'l' or 'r' })
-
- local setting = timed_save and _p('plugin-hiscore', 'When updated') or _p('plugin-hiscore', 'On exit')
- table.insert(items, { _p('plugin-hiscore', 'Save scores'), setting, timed_save and 'l' or 'r' })
-
- return items
+ local items = { }
+ local setting = timed_save and _p('plugin-hiscore', 'When updated') or _p('plugin-hiscore', 'On exit')
+ table.insert(items, { _p('plugin-hiscore', 'Hiscore Support Options'), '', 'off' })
+ table.insert(items, { '---', '', '' })
+ table.insert(items, { _p('plugin-hiscore', 'Save scores'), setting, timed_save and 'l' or 'r' })
+ return items
end
-- handle menu events
local function handle_menu(index, event)
-
- -- added menu item to enable/disable hiscore support for this game
- if index == 3 then
- if event == 'left' or event == 'right' then
- local game = emu.romname()
- if event == 'left' then
- -- Disable Hiscore Support for this game (add to exclude list)
- excluded_games[game] = true
- emu.print_verbose(string.format('[Hiscore] Hiscore support disabled for game "%s"', game))
- elseif event == 'right' then
- -- Enable Hiscore Support for this game (remove from exclude list)
- excluded_games[game] = nil
- emu.print_verbose(string.format('[Hiscore] Hiscore support enabled for game "%s"', game))
- end
- save_exclusions()
- return true
- else
- return false
- end
- end
-
- -- previous menu item to select when scores are saved remains unchanged (now on menu index #4)
- if index == 4 then
if event == 'left' then
- timed_save = false
- return true
+ timed_save = false
+ return true
elseif event == 'right' then
- timed_save = true
- return true
+ timed_save = true
+ return true
end
- end
- return false
+ return false
end
-
local hiscoredata_path = "hiscore.dat";
local current_checksum = 0;
@@ -305,12 +220,6 @@ function hiscore.startplugin()
local function write_scores ( posdata )
- -- check if game is on the exclude list before writing
- if is_game_excluded() then
- emu.print_verbose('[Hiscore] Skipping write_scores - excluded game: ' .. emu.romname())
- return
- end
-
emu.print_verbose("hiscore: write_scores")
local output = io.open(get_file_name(), "wb");
if not output then
@@ -334,12 +243,6 @@ function hiscore.startplugin()
local function read_scores ( posdata )
- -- check if game is on the exclude list before loading scores
- if is_game_excluded() then
- emu.print_verbose('[Hiscore] Skipping read_scores - excluded game: ' .. emu.romname())
- return false
- end
-
local input = io.open(get_file_name(), "rb");
if input then
for ri,row in ipairs(posdata) do
@@ -433,9 +336,6 @@ function hiscore.startplugin()
last_write_time = -10
emu.print_verbose("Starting " .. emu.gamename())
read_config();
-
- -- re-load game exclusions list on reset
- load_exclusions();
local dat = read_hiscore_dat()
if dat and dat ~= "" then
emu.print_verbose( "hiscore: found hiscore.dat entry for " .. emu.romname() );