From 4c8b753caa7e1dfc5c5d8ea26117a8d20c670d75 Mon Sep 17 00:00:00 2001 From: Waterpig <49160555+Majkl-J@users.noreply.github.com> Date: Mon, 26 Feb 2024 11:58:20 +0100 Subject: [PATCH] Minesweeper rightclicks (#1211) ## About The Pull Request Fixes the rightclicking to flag in minesweeper Also puts it in the game category ## Proof Of Testing dude trust me ## Changelog :cl: fix: you can now rightclick to flag in minesweeper /:cl: --- .../code/game/machinery/computer/arcade.dm | 171 --------------- .../machinery/computer/arcade}/minesweeper.dm | 195 +++++++++++++++++- .../circuitboards/computer_circuitboards.dm | 4 - tgstation.dme | 4 +- tgui/packages/tgui/interfaces/Minesweeper.jsx | 2 +- 5 files changed, 190 insertions(+), 186 deletions(-) delete mode 100644 modular_zubbers/code/game/machinery/computer/arcade.dm rename modular_zubbers/code/{modules/modular_computers/file_system/programs => game/machinery/computer/arcade}/minesweeper.dm (66%) delete mode 100644 modular_zubbers/code/game/objects/items/circuitboards/computer_circuitboards.dm diff --git a/modular_zubbers/code/game/machinery/computer/arcade.dm b/modular_zubbers/code/game/machinery/computer/arcade.dm deleted file mode 100644 index e535f1c632b..00000000000 --- a/modular_zubbers/code/game/machinery/computer/arcade.dm +++ /dev/null @@ -1,171 +0,0 @@ -#define MINESWEEPER_BEGINNER 1 -#define MINESWEEPER_INTERMEDIATE 2 -#define MINESWEEPER_EXPERT 3 -#define MINESWEEPER_CUSTOM 4 - -#define MINESWEEPER_CONTINUE 0 -#define MINESWEEPER_DEAD 1 -#define MINESWEEPER_VICTORY 2 -#define MINESWEEPER_IDLE 3 -/obj/machinery/computer/arcade/minesweeper - name = "Minesweeper" - desc = "An arcade machine that generates grids. It seems that the machine sparks and screeches when a grid is generated, as if it cannot cope with the intensity of generating the grid." - icon_state = "arcade" - circuit = /obj/item/circuitboard/computer/arcade/minesweeper - - var/datum/minesweeper/board - -/obj/machinery/computer/arcade/minesweeper/Initialize() - . = ..() - board = new /datum/minesweeper() - board.emaggable = TRUE - board.host = src - -/obj/machinery/computer/arcade/minesweeper/Destroy(force) - board.host = null - QDEL_NULL(board) - . = ..() - -/obj/machinery/computer/arcade/minesweeper/interact(mob/user, special_state) - . = ..() - if(!is_operational) - return - if(board.game_status == MINESWEEPER_IDLE || board.game_status == MINESWEEPER_DEAD || board.game_status == MINESWEEPER_VICTORY) - if(obj_flags & EMAGGED) - playsound(loc, 'modular_zubbers/sound/arcade/minesweeper_emag2.ogg', 50, 0, extrarange = -3, falloff_exponent = 10) - else - playsound(loc, 'modular_zubbers/sound/arcade/minesweeper_startup.ogg', 50, 0, extrarange = -3, falloff_exponent = 10) - - if(obj_flags & EMAGGED) - do_sparks(5, 1, src) - - add_fingerprint(user) - -/obj/machinery/computer/arcade/minesweeper/ui_interact(mob/user, datum/tgui/ui) - . = ..() - ui = SStgui.try_update_ui(user, src, ui) - if(!is_operational) - return - if(!ui) - ui = new(user, src, "Minesweeper", name) - ui.open() - -/obj/machinery/computer/arcade/minesweeper/ui_assets(mob/user) - return list( - get_asset_datum(/datum/asset/simple/minesweeper), - ) - -/obj/machinery/computer/arcade/minesweeper/ui_data(mob/user) - var/list/data = ..() - - data["board_data"] = board.board_data - data["game_status"] = board.game_status - data["difficulty"] = board.diff_text(board.difficulty) - data["current_difficulty"] = board.current_difficulty - data["emagged"] = obj_flags & EMAGGED - data["flag_mode"] = board.flag_mode - data["tickets"] = board.ticket_count - data["flags"] = board.flags - data["current_mines"] = board.current_mines - data["custom_height"] = board.custom_height - data["custom_width"] = board.custom_width - data["custom_mines"] = board.custom_mines - var/display_time = (board.time_frozen ? board.time_frozen : REALTIMEOFDAY - board.starting_time) / 10 - data["time_string"] = board.starting_time ? "[add_leading(num2text(FLOOR(display_time / 60,1)), 2, "0")]:[add_leading(num2text(display_time % 60), 2, "0")]" : "00:00" - - return data - -/obj/machinery/computer/arcade/minesweeper/ui_act(action, list/params, mob/user) - if(..()) - return TRUE - - switch(action) - if("PRG_do_tile") - var/x = params["x"] - var/y = params["y"] - var/flagging = params["flag"] - if(!x || !y) - return - - return board.do_tile(x,y,flagging,user) - - if("PRG_new_game") - board.play_snd('modular_zubbers/sound/arcade/minesweeper_boardpress.ogg') - board.generate_new_board(board.difficulty) - board.current_difficulty = board.diff_text(board.difficulty) - board.current_mines = board.mines - board.flags = 0 - board.starting_time = 0 - return TRUE - - if("PRG_difficulty") - var/diff = params["difficulty"] - if(!diff) - return - board.play_snd('modular_zubbers/sound/arcade/minesweeper_boardpress.ogg') - board.difficulty = diff - return TRUE - - if("PRG_height") - var/cin = params["height"] - if(!cin) - return - cin = text2num(cin) - if(cin < 5 || cin > 17) - cin = clamp(cin, 5, 17) - board.custom_height = cin - board.custom_mines = min(board.custom_mines, FLOOR(board.custom_width*board.custom_height/2,1)) - board.difficulty = MINESWEEPER_CUSTOM - return TRUE - - if("PRG_width") - var/cin = params["width"] - if(!cin) - return - cin = text2num(cin) - if(cin < 5 || cin > 30) - cin = clamp(cin, 5, 30) - board.custom_width = cin - board.custom_mines = min(board.custom_mines, FLOOR(board.custom_width*board.custom_height/2,1)) - board.difficulty = MINESWEEPER_CUSTOM - return TRUE - - if("PRG_mines") - var/cin = params["mines"] - if(!cin) - return - cin = text2num(cin) - if(cin < 5 || cin > FLOOR(board.custom_width*board.custom_height/2,1)) - cin = clamp(cin, 5, FLOOR(board.custom_width*board.custom_height/2,1)) - board.custom_mines = cin - board.difficulty = MINESWEEPER_CUSTOM - return TRUE - - if("PRG_toggle_flag") - board.play_snd('modular_zubbers/sound/arcade/minesweeper_boardpress.ogg') - board.flag_mode = !board.flag_mode - return TRUE - - if("PRG_tickets") - board.play_snd('modular_zubbers/sound/arcade/minesweeper_boardpress.ogg') - if(board.ticket_count >= 1) - new /obj/item/stack/arcadeticket(loc, 1) - to_chat(user, span_notice("[src] dispenses a ticket!")) - board.ticket_count -= 1 - else - to_chat(user, span_notice("You don't have any stored tickets!")) - return TRUE - -/obj/machinery/computer/arcade/minesweeper/emag_act(mob/user) - if(obj_flags & EMAGGED) - return - desc = "An arcade machine that generates grids. It's clunking and sparking everywhere, almost as if threatening to explode at any moment!" - do_sparks(5, 1, src) - obj_flags |= EMAGGED - if(board.game_status != MINESWEEPER_CONTINUE) - to_chat(user, span_warning("An ominous tune plays from the arcade's speakers!")) - playsound(user, 'modular_zubbers/sound/arcade/minesweeper_emag1.ogg', 100, 0, extrarange = 3, falloff_exponent = 10) - else //Can't let you do that, star fox! - to_chat(user, span_warning("The machine buzzes and sparks... the game has been reset!")) - playsound(user, 'sound/machines/buzz-sigh.ogg', 100, 0, extrarange = 3, falloff_exponent = 10) //Loud buzz - board.game_status = MINESWEEPER_IDLE diff --git a/modular_zubbers/code/modules/modular_computers/file_system/programs/minesweeper.dm b/modular_zubbers/code/game/machinery/computer/arcade/minesweeper.dm similarity index 66% rename from modular_zubbers/code/modules/modular_computers/file_system/programs/minesweeper.dm rename to modular_zubbers/code/game/machinery/computer/arcade/minesweeper.dm index 6d787cc8fb5..c400fe7ca22 100644 --- a/modular_zubbers/code/modules/modular_computers/file_system/programs/minesweeper.dm +++ b/modular_zubbers/code/game/machinery/computer/arcade/minesweeper.dm @@ -1,13 +1,198 @@ +/obj/item/circuitboard/computer/arcade/minesweeper + name = "Minesweeper" + greyscale_colors = CIRCUIT_COLOR_GENERIC + build_path = /obj/machinery/computer/arcade/minesweeper + +#define MINESWEEPER_BEGINNER 1 +#define MINESWEEPER_INTERMEDIATE 2 +#define MINESWEEPER_EXPERT 3 +#define MINESWEEPER_CUSTOM 4 + +#define MINESWEEPER_CONTINUE 0 +#define MINESWEEPER_DEAD 1 +#define MINESWEEPER_VICTORY 2 +#define MINESWEEPER_IDLE 3 + +/* MINESWEEPER MACHINE */ +/// The machine itself. + +/obj/machinery/computer/arcade/minesweeper + name = "Minesweeper" + desc = "An arcade machine that generates grids. It seems that the machine sparks and screeches when a grid is generated, as if it cannot cope with the intensity of generating the grid." + icon_state = "arcade" + circuit = /obj/item/circuitboard/computer/arcade/minesweeper + + var/datum/minesweeper/board + +/obj/machinery/computer/arcade/minesweeper/Initialize() + . = ..() + board = new /datum/minesweeper() + board.emaggable = TRUE + board.host = src + +/obj/machinery/computer/arcade/minesweeper/Destroy(force) + board.host = null + QDEL_NULL(board) + . = ..() + +/obj/machinery/computer/arcade/minesweeper/interact(mob/user, special_state) + . = ..() + if(!is_operational) + return + if(board.game_status == MINESWEEPER_IDLE || board.game_status == MINESWEEPER_DEAD || board.game_status == MINESWEEPER_VICTORY) + if(obj_flags & EMAGGED) + playsound(loc, 'modular_zubbers/sound/arcade/minesweeper_emag2.ogg', 50, 0, extrarange = -3, falloff_exponent = 10) + else + playsound(loc, 'modular_zubbers/sound/arcade/minesweeper_startup.ogg', 50, 0, extrarange = -3, falloff_exponent = 10) + + if(obj_flags & EMAGGED) + do_sparks(5, 1, src) + + add_fingerprint(user) + +/obj/machinery/computer/arcade/minesweeper/ui_interact(mob/user, datum/tgui/ui) + . = ..() + ui = SStgui.try_update_ui(user, src, ui) + if(!is_operational) + return + if(!ui) + ui = new(user, src, "Minesweeper", name) + ui.open() + +/obj/machinery/computer/arcade/minesweeper/ui_assets(mob/user) + return list( + get_asset_datum(/datum/asset/simple/minesweeper), + ) + +/obj/machinery/computer/arcade/minesweeper/ui_data(mob/user) + var/list/data = ..() + + data["board_data"] = board.board_data + data["game_status"] = board.game_status + data["difficulty"] = board.diff_text(board.difficulty) + data["current_difficulty"] = board.current_difficulty + data["emagged"] = obj_flags & EMAGGED + data["flag_mode"] = board.flag_mode + data["tickets"] = board.ticket_count + data["flags"] = board.flags + data["current_mines"] = board.current_mines + data["custom_height"] = board.custom_height + data["custom_width"] = board.custom_width + data["custom_mines"] = board.custom_mines + var/display_time = (board.time_frozen ? board.time_frozen : REALTIMEOFDAY - board.starting_time) / 10 + data["time_string"] = board.starting_time ? "[add_leading(num2text(FLOOR(display_time / 60,1)), 2, "0")]:[add_leading(num2text(display_time % 60), 2, "0")]" : "00:00" + + return data + +/obj/machinery/computer/arcade/minesweeper/ui_act(action, list/params, mob/user) + if(..()) + return TRUE + + switch(action) + if("PRG_do_tile") + var/x = params["x"] + var/y = params["y"] + var/flagging = params["flag"] + if(!x || !y) + return + + return board.do_tile(x,y,flagging,user) + + if("PRG_new_game") + board.play_snd('modular_zubbers/sound/arcade/minesweeper_boardpress.ogg') + board.generate_new_board(board.difficulty) + board.current_difficulty = board.diff_text(board.difficulty) + board.current_mines = board.mines + board.flags = 0 + board.starting_time = 0 + return TRUE + + if("PRG_difficulty") + var/diff = params["difficulty"] + if(!diff) + return + board.play_snd('modular_zubbers/sound/arcade/minesweeper_boardpress.ogg') + board.difficulty = diff + return TRUE + + if("PRG_height") + var/cin = params["height"] + if(!cin) + return + cin = text2num(cin) + if(cin < 5 || cin > 17) + cin = clamp(cin, 5, 17) + board.custom_height = cin + board.custom_mines = min(board.custom_mines, FLOOR(board.custom_width*board.custom_height/2,1)) + board.difficulty = MINESWEEPER_CUSTOM + return TRUE + + if("PRG_width") + var/cin = params["width"] + if(!cin) + return + cin = text2num(cin) + if(cin < 5 || cin > 30) + cin = clamp(cin, 5, 30) + board.custom_width = cin + board.custom_mines = min(board.custom_mines, FLOOR(board.custom_width*board.custom_height/2,1)) + board.difficulty = MINESWEEPER_CUSTOM + return TRUE + + if("PRG_mines") + var/cin = params["mines"] + if(!cin) + return + cin = text2num(cin) + if(cin < 5 || cin > FLOOR(board.custom_width*board.custom_height/2,1)) + cin = clamp(cin, 5, FLOOR(board.custom_width*board.custom_height/2,1)) + board.custom_mines = cin + board.difficulty = MINESWEEPER_CUSTOM + return TRUE + + if("PRG_toggle_flag") + board.play_snd('modular_zubbers/sound/arcade/minesweeper_boardpress.ogg') + board.flag_mode = !board.flag_mode + return TRUE + + if("PRG_tickets") + board.play_snd('modular_zubbers/sound/arcade/minesweeper_boardpress.ogg') + if(board.ticket_count >= 1) + new /obj/item/stack/arcadeticket(loc, 1) + to_chat(user, span_notice("[src] dispenses a ticket!")) + board.ticket_count -= 1 + else + to_chat(user, span_notice("You don't have any stored tickets!")) + return TRUE + +/obj/machinery/computer/arcade/minesweeper/emag_act(mob/user) + if(obj_flags & EMAGGED) + return + desc = "An arcade machine that generates grids. It's clunking and sparking everywhere, almost as if threatening to explode at any moment!" + do_sparks(5, 1, src) + obj_flags |= EMAGGED + if(board.game_status != MINESWEEPER_CONTINUE) + to_chat(user, span_warning("An ominous tune plays from the arcade's speakers!")) + playsound(user, 'modular_zubbers/sound/arcade/minesweeper_emag1.ogg', 100, 0, extrarange = 3, falloff_exponent = 10) + else //Can't let you do that, star fox! + to_chat(user, span_warning("The machine buzzes and sparks... the game has been reset!")) + playsound(user, 'sound/machines/buzz-sigh.ogg', 100, 0, extrarange = 3, falloff_exponent = 10) //Loud buzz + board.game_status = MINESWEEPER_IDLE + + + + +/// COMPUTER MINESWEEPER PROGRAM /datum/computer_file/program/minesweeper filename = "minesweeper" filedesc = "Nanotrasen Micro Arcade: Minesweeper" -// program_icon_state = "arcade" extended_desc = "A port of the classic game 'Minesweeper', redesigned to run on tablets." -// requires_ntnet = FALSE size = 6 tgui_id = "NtosMinesweeper" program_icon = "gamepad" + downloader_category = PROGRAM_CATEGORY_GAMES + var/datum/minesweeper/board /datum/computer_file/program/minesweeper/New(obj/item/modular_computer/comp) @@ -144,11 +329,7 @@ COOLDOWN_DECLARE(new_game_cd) /datum/minesweeper/proc/play_snd(sound) - /*if(istype(host, /obj/item/modular_computer)) - var/obj/item/modular_computer/comp = host - playsound(get_turf(), sound, 50, 0) - else*/ - playsound(get_turf(host), sound, 50, 0, extrarange = -3, falloff_exponent = 10) + playsound(get_turf(host), sound, 25, 0, extrarange = -6) /datum/minesweeper/proc/vis_msg(msg, local_msg) if(istype(host, /obj/item/modular_computer)) diff --git a/modular_zubbers/code/game/objects/items/circuitboards/computer_circuitboards.dm b/modular_zubbers/code/game/objects/items/circuitboards/computer_circuitboards.dm deleted file mode 100644 index f3d3d78277a..00000000000 --- a/modular_zubbers/code/game/objects/items/circuitboards/computer_circuitboards.dm +++ /dev/null @@ -1,4 +0,0 @@ -/obj/item/circuitboard/computer/arcade/minesweeper - name = "Minesweeper" - greyscale_colors = CIRCUIT_COLOR_GENERIC - build_path = /obj/machinery/computer/arcade/minesweeper diff --git a/tgstation.dme b/tgstation.dme index df405d07b57..b49cfbf1b21 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -8218,7 +8218,6 @@ #include "modular_zubbers\code\game\machinery\burger_reactor_sniffer\reactor_sniffer_processing.dm" #include "modular_zubbers\code\game\machinery\burger_reactor_sniffer\reactor_sniffer_wires.dm" #include "modular_zubbers\code\game\machinery\camera\camera.dm" -#include "modular_zubbers\code\game\machinery\computer\arcade.dm" #include "modular_zubbers\code\game\machinery\computer\crew.dm" #include "modular_zubbers\code\game\machinery\computer\arcade\arcade.dm" #include "modular_zubbers\code\game\machinery\computer\arcade\arcade_weights_classic.dm" @@ -8226,6 +8225,7 @@ #include "modular_zubbers\code\game\machinery\computer\arcade\arcade_weights_oh_god.dm" #include "modular_zubbers\code\game\machinery\computer\arcade\arcade_weights_special.dm" #include "modular_zubbers\code\game\machinery\computer\arcade\arcade_weights_toy.dm" +#include "modular_zubbers\code\game\machinery\computer\arcade\minesweeper.dm" #include "modular_zubbers\code\game\machinery\computer\arcade\~arcade_weights_final.dm" #include "modular_zubbers\code\game\machinery\doors\firedoor.dm" #include "modular_zubbers\code\game\machinery\vending\multisec.dm" @@ -8240,7 +8240,6 @@ #include "modular_zubbers\code\game\objects\items\plushes.dm" #include "modular_zubbers\code\game\objects\items\reshirevolver.dm" #include "modular_zubbers\code\game\objects\items\ai_modules\full_lawsets.dm" -#include "modular_zubbers\code\game\objects\items\circuitboards\computer_circuitboards.dm" #include "modular_zubbers\code\game\objects\items\circuitboards\machine_circuitboards.dm" #include "modular_zubbers\code\game\objects\items\food\halloween_chocolate.dm" #include "modular_zubbers\code\game\objects\items\food\meatslab.dm" @@ -8447,7 +8446,6 @@ #include "modular_zubbers\code\modules\mod\mod_ai.dm" #include "modular_zubbers\code\modules\mod\mod_theme.dm" #include "modular_zubbers\code\modules\mod\mod_types.dm" -#include "modular_zubbers\code\modules\modular_computers\file_system\programs\minesweeper.dm" #include "modular_zubbers\code\modules\movespeed\modifiers\status_effects.dm" #include "modular_zubbers\code\modules\opposing_force\code\items.dm" #include "modular_zubbers\code\modules\opposing_force\code\equipment\antagonist_powers.dm" diff --git a/tgui/packages/tgui/interfaces/Minesweeper.jsx b/tgui/packages/tgui/interfaces/Minesweeper.jsx index 9443695ffa3..0e09303d493 100644 --- a/tgui/packages/tgui/interfaces/Minesweeper.jsx +++ b/tgui/packages/tgui/interfaces/Minesweeper.jsx @@ -65,7 +65,7 @@ export const MinesweeperContent = (props, context) => { flag: false, }) } - oncontextmenu={(eve) => { + onContextMenu={(eve) => { eve.preventDefault(); act('PRG_do_tile', { x: xind + 1,