From c76d00bc3c9a2e977464957872575acde5a90131 Mon Sep 17 00:00:00 2001 From: Luke Hubmayer-Werner Date: Fri, 4 Aug 2023 18:17:08 +0930 Subject: [PATCH] Add string loading Required for party menu changes Also move menu colour to a new Manager Common is now a Manager too Rename the loaders from snake_case --- PC.gd | 2 + data/glyph_tables/Glyphs_dialog_RPGe.txt | 256 +++++++++++ data/glyph_tables/Glyphs_dialog_SNES.txt | 256 +++++++++++ .../glyph_tables/Glyphs_dialog_kanji_SNES.txt | 426 ++++++++++++++++++ data/glyph_tables/Glyphs_small_RPGe.txt | 256 +++++++++++ data/glyph_tables/Glyphs_small_SNES.txt | 256 +++++++++++ .../Glyphs_small_dakuten_SNES.txt | 256 +++++++++++ data/string_blocks.tsv | 12 + main_menu.tscn | 8 +- project.godot | 16 +- .../loaders/{map_loader.gd => MapLoader.gd} | 0 .../loaders/{rom_loader.gd => RomLoader.gd} | 1 + .../loaders/{save_loader.gd => SaveLoader.gd} | 6 + .../{sound_loader.gd => SoundLoader.gd} | 0 .../{sprite_loader.gd => SpriteLoader.gd} | 0 scripts/loaders/StringLoader.gd | 97 ++++ .../loaders/{common_gba.gd => gba/common.gd} | 0 .../{loaders/common.gd => managers/Common.gd} | 59 ++- scripts/managers/ThemeManager.gd | 33 ++ scripts/struct.gd | 3 +- test_scene.gd | 5 +- test_scene.tscn | 13 +- widgets/ColorMenu.gd | 15 +- widgets/PartyMenu.gd | 21 + party_menu.tscn => widgets/PartyMenu.tscn | 30 +- widgets/PartyMenuCharacter.gd | 40 +- widgets/PartyMenuCharacter.tscn | 212 +++++---- widgets/SaveSlot.gd | 5 +- 28 files changed, 2126 insertions(+), 158 deletions(-) create mode 100644 data/glyph_tables/Glyphs_dialog_RPGe.txt create mode 100644 data/glyph_tables/Glyphs_dialog_SNES.txt create mode 100644 data/glyph_tables/Glyphs_dialog_kanji_SNES.txt create mode 100644 data/glyph_tables/Glyphs_small_RPGe.txt create mode 100644 data/glyph_tables/Glyphs_small_SNES.txt create mode 100644 data/glyph_tables/Glyphs_small_dakuten_SNES.txt create mode 100644 data/string_blocks.tsv rename scripts/loaders/{map_loader.gd => MapLoader.gd} (100%) rename scripts/loaders/{rom_loader.gd => RomLoader.gd} (97%) rename scripts/loaders/{save_loader.gd => SaveLoader.gd} (93%) rename scripts/loaders/{sound_loader.gd => SoundLoader.gd} (100%) rename scripts/loaders/{sprite_loader.gd => SpriteLoader.gd} (100%) create mode 100644 scripts/loaders/StringLoader.gd rename scripts/loaders/{common_gba.gd => gba/common.gd} (100%) rename scripts/{loaders/common.gd => managers/Common.gd} (82%) create mode 100644 scripts/managers/ThemeManager.gd create mode 100644 widgets/PartyMenu.gd rename party_menu.tscn => widgets/PartyMenu.tscn (89%) diff --git a/PC.gd b/PC.gd index b1355a7..7709203 100644 --- a/PC.gd +++ b/PC.gd @@ -50,6 +50,8 @@ func _process(_delta): # pass func _draw(): + if self.texture == null: + return var frames = Animation_Frames[animation] var frame = frames[int(globals.time*4) % len(frames)] var y = 0 diff --git a/data/glyph_tables/Glyphs_dialog_RPGe.txt b/data/glyph_tables/Glyphs_dialog_RPGe.txt new file mode 100644 index 0000000..eedb266 --- /dev/null +++ b/data/glyph_tables/Glyphs_dialog_RPGe.txt @@ -0,0 +1,256 @@ + +\n + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +バ +ば +ビ +び +ブ +ぶ +ベ +べ +ボ +ぼ +ガ +が +ギ +ぎ +グ +ぐ +ゲ +げ +ゴ +ご +ザ +ざ +ジ +じ +ズ +ず +ゼ +ぜ +ゾ +ぞ +ダ +だ +ヂ +ぢ +ヅ +づ +デ +で +ド +ど +ヴ +パ +ぱ +ピ +ぴ +プ +ぷ +ペ +" +' + +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +_m +_H +_P +A +B +C +D +E +F +G +H +I +J +K +L +M +N +O +P +Q +R +S +T +U +V +W +X +Y +Z +a +b +c +d +e +f +g +h +i +j +k +l +m +n +o +p +q +r +s +t +u +v +w +x +y +z +il +it + +li +ll +' +" +: +; +, +( +) +/ +! +? +. +ti +fi +ラ +ら +pe +l +' +" +if +lt +tl +ir +tt +や +ユ +ゆ +ヨ +よ +ワ +わ +ン +ん +ヲ +を +ッ +っ +ャ +ゃ +ュ +ゅ +ョ +ょ +ァ +ー +ィ +⋯ +ぅ +! +ェ +? +ォ +% +/ +: +「 +」 +。 +A +B +X +Y +L +R +E +H +M +P +S +C +T +← +→ ++ +、 +◯ +『 +F +°C +・ +( +) + + + + + + + + + + + + + + + + + + + + + diff --git a/data/glyph_tables/Glyphs_dialog_SNES.txt b/data/glyph_tables/Glyphs_dialog_SNES.txt new file mode 100644 index 0000000..eee56e1 --- /dev/null +++ b/data/glyph_tables/Glyphs_dialog_SNES.txt @@ -0,0 +1,256 @@ +  +\n +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +バ +ば +ビ +び +ブ +ぶ +ベ +べ +ボ +ぼ +ガ +が +ギ +ぎ +グ +ぐ +ゲ +げ +ゴ +ご +ザ +ざ +ジ +じ +ズ +ず +ゼ +ぜ +ゾ +ぞ +ダ +だ +ヂ +ぢ +ヅ +づ +デ +で +ド +ど +ヴ +パ +ぱ +ピ +ぴ +プ +ぷ +ペ +ぺ +ポ +ぽ +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +_m +_H +_P +ハ +は +ヒ +ひ +フ +ふ +ヘ +へ +ホ +ほ +カ +か +キ +き +ク +く +ケ +け +コ +こ +サ +さ +シ +し +ス +す +セ +せ +ソ +そ +タ +た +チ +ち +ツ +つ +テ +て +ト +と +ウ +う +ア +あ +イ +い +エ +え +オ +お +ナ +な +ニ +に +ヌ +ぬ +ネ +ね +ノ +の +マ +ま +ミ +み +ム +む +メ +め +モ +も +ラ +ら +リ +り +ル +る +レ +れ +ロ +ろ +ヤ +や +ユ +ゆ +ヨ +よ +ワ +わ +ン +ん +ヲ +を +ッ +っ +ャ +ゃ +ュ +ゅ +ョ +ょ +ァ +ー +ィ +⋯ +ぅ +! +ェ +? +ォ +% +/ +: +「 +」 +。 +A +B +X +Y +L +R +E +H +M +P +S +C +T +← +→ ++ +、 +◯ +『 +F +°C +・ +( +) +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  diff --git a/data/glyph_tables/Glyphs_dialog_kanji_SNES.txt b/data/glyph_tables/Glyphs_dialog_kanji_SNES.txt new file mode 100644 index 0000000..5306635 --- /dev/null +++ b/data/glyph_tables/Glyphs_dialog_kanji_SNES.txt @@ -0,0 +1,426 @@ +王 +行 +力 +様 +飛 +世 +界 +封 +入 +城 +竜 +士 +船 +印 +海 +父 +人 +見 +魔 +物 +大 +者 +本 +何 +戦 +出 +気 +手 +言 +石 +守 +辺 +無 +心 +間 +前 +風 +帰 +私 +生 +年 +武 +器 +兵 +火 +使 +中 +急 +時 +森 +来 +砂 +動 +女 +待 +臣 +地 +助 +当 +今 +上 +悪 +泉 +騎 +思 +持 +変 +水 +塔 +草 +仲 +復 +目 +作 +分 +知 +機 +一 +姫 +最 +聞 +械 +神 +流 +乗 +取 +町 +殿 +事 +空 +勇 +村 +早 +子 +格 +納 +伝 +消 +書 +長 +話 +合 +所 +場 +脱 +北 +後 +全 +忍 +獣 +詩 +吟 +落 +自 +階 +説 +残 +親 +活 +休 +姉 +破 +土 +度 +記 +発 +赤 +侍 +死 +国 +旅 +完 +小 +林 +古 +図 +礼 +商 +島 +邪 +部 +狩 +精 +姿 +防 +向 +先 +解 +板 +下 +台 +賢 +対 +木 +成 +命 +配 +法 +飲 +回 +願 +門 +東 +開 +貸 +増 +危 +舘 +道 +身 +老 +西 +近 +層 +第 +青 +光 +読 +外 +理 +強 +同 +谷 +負 +意 +学 +攻 +屋 +体 +運 +河 +聖 +必 +南 +方 +黒 +絶 +食 +艇 +山 +穴 +名 +受 +暁 +傷 +少 +鼻 +倉 +然 +的 +男 +用 +酒 +安 +現 +代 +立 +具 +育 +続 +通 +会 +庫 +飼 +日 +窟 +砲 +広 +化 +博 +以 +兄 +室 +洞 +別 +番 +昔 +住 +吸 +去 +宝 +毒 +売 +好 +枝 +踊 +月 +巣 +底 +明 +感 +宿 +召 +喚 +決 +形 +団 +異 +初 +険 +家 +息 +連 +集 +墓 +著 +跡 +遺 +内 +悲 +教 +返 +頭 +再 +高 +借 +登 +走 +過 +敵 +鏡 +愛 +魚 +燃 +幅 +音 +血 +滝 +次 +閉 +求 +声 +箱 +軍 +泣 +港 +冊 +秒 +憶 +潜 +爆 +恋 +石 +左 +役 +放 +衛 +母 +建 +角 +信 +師 +元 +失 +字 +歩 +遊 +頂 +震 +収 +追 +暗 +橋 +起 +約 +束 +文 +反 +絵 +能 +歌 +弱 +境 +波 +針 +千 +炎 +望 +雨 +金 +希 +花 +不 +白 +剣 +陸 +勝 +烏 +笛 +究 +三 +探 +夜 +病 +半 +美 +敗 +友 +研 +予 +支 +々 +除 +数 +店 +翼 +充 +填 +薬 +弟 +経 +験 +値 +闘 +得 +闇 +混 +乱 +点 +速 +閃 +射 +斬 +鉄 +宣 +告 +電 +磁 +圧 +昇 +重 +倍 +妖 +刀 +拡 +散 +影 +御 +正 +漠 +特 +胸 +永 +遠 +議 +浮 +眠 +逃 +滅 +囗 +極 +湖 +利 +周 +緑 +切 +紙 +胸 +平 +和 +宇 +宙 +則 +孤 +溝 +  diff --git a/data/glyph_tables/Glyphs_small_RPGe.txt b/data/glyph_tables/Glyphs_small_RPGe.txt new file mode 100644 index 0000000..5f3ffab --- /dev/null +++ b/data/glyph_tables/Glyphs_small_RPGe.txt @@ -0,0 +1,256 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +A +B +C +D +E +F +G +H +I +J +K +L +M +N +O +P +Q +R +S +T +U +V +W +X +Y +Z +[stone] +[toad] +[mini] +[float] +[poison] +[KO] +[blind] + + + + + + + + + + + + + + + + + + +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +_m +_H +_P +A +B +C +D +E +F +G +H +I +J +K +L +M +N +O +P +Q +R +S +T +U +V +W +X +Y +Z +a +b +c +d +e +f +g +h +i +j +k +l +m +n +o +p +q +r +s +t +u +v +w +x +y +z +il +it + +li +ll +' +" +: +; +, +( +) +/ +! +? +. +ti +fi +Bl +a +pe +l +' +" +if +lt +tl +ir +tt +や +ユ +ゆ +ヨ +よ +ワ +わ +ン +ん +ヲ +を +[key] +[shoe] +◆ +[hammer] +⛺ +[ribbon] +[potion] +[shirt] +♪ +- +[shuriken] +‥ +[scroll] +! +[claw] +? +[glove] +% +/ +: +「 +」 +. +A +B +X +Y +L +R +E +H +M +P +S +C +T +↑ +→ ++ +[sword] +[wh.mag] +[blk.mag] +🕒 +[knife] +[spear] +[axe] +[katana] +[rod] +[staff] +[bow] +[harp] +[whip] +[bell] +[shield] +[helmet] +[armor] +[ring] + + + + + + + + + + + diff --git a/data/glyph_tables/Glyphs_small_SNES.txt b/data/glyph_tables/Glyphs_small_SNES.txt new file mode 100644 index 0000000..5b4fe13 --- /dev/null +++ b/data/glyph_tables/Glyphs_small_SNES.txt @@ -0,0 +1,256 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +A +B +C +D +E +F +G +H +I +J +K +L +M +N +O +P +Q +R +S +T +U +V +W +X +Y +Z +[stone] +[toad] +[mini] +[float] +[poison] +[KO] +[blind] + + + + + + + + + + + + + + + + + + +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +_m +_H +_P +ハ +は +ヒ +ひ +フ +ふ +ヘ +へ +ホ +ほ +カ +か +キ +き +ク +く +ケ +け +コ +こ +サ +さ +シ +し +ス +す +セ +せ +ソ +そ +タ +た +チ +ち +ツ +つ +テ +て +ト +と +ウ +う +ア +あ +イ +い +エ +え +オ +お +ナ +な +ニ +に +ヌ +ぬ +ネ +ね +ノ +の +マ +ま +ミ +み +ム +む +メ +め +モ +も +ラ +ら +リ +り +ル +る +レ +れ +ロ +ろ +ヤ +や +ユ +ゆ +ヨ +よ +ワ +わ +ン +ん +ヲ +を +ッ +っ +ャ +ゃ +ュ +ゅ +ョ +ょ +ァ +ー +ィ +‥ +ぅ +! +ェ +? +ォ +% +/ +: +「 +」 +。 +A +B +X +Y +L +R +E +H +M +P +S +C +T +↑ +→ ++ +[洋剣] +[wh.mag] +[blk.mag] +🕒 +[刂] +[槍] +[鉞] +[刀] +[棒] +[杖] +[弓] +♪ +[鞭] +[bell] +[shield] +[helmet] +[armor] +[ring] + + + + + + + + + + + diff --git a/data/glyph_tables/Glyphs_small_dakuten_SNES.txt b/data/glyph_tables/Glyphs_small_dakuten_SNES.txt new file mode 100644 index 0000000..86852b5 --- /dev/null +++ b/data/glyph_tables/Glyphs_small_dakuten_SNES.txt @@ -0,0 +1,256 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +バ +ば +ビ +び +ブ +ぶ +ベ +べ +ボ +ぼ +ガ +が +ギ +ぎ +グ +ぐ +ゲ +げ +ゴ +ご +ザ +ざ +ジ +じ +ズ +ず +ゼ +ぜ +ゾ +ぞ +ダ +だ +ヂ +ぢ +ヅ +づ +デ +で +ド +ど +ヴ +パ +ぱ +ピ +ぴ +プ +ぷ +ペ +ぺ +ポ +ぽ +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +_m +_H +_P +ハ +は +ヒ +ひ +フ +ふ +ヘ +へ +ホ +ほ +カ +か +キ +き +ク +く +ケ +け +コ +こ +サ +さ +シ +し +ス +す +セ +せ +ソ +そ +タ +た +チ +ち +ツ +つ +テ +て +ト +と +ウ +う +ア +あ +イ +い +エ +え +オ +お +ナ +な +ニ +に +ヌ +ぬ +ネ +ね +ノ +の +マ +ま +ミ +み +ム +む +メ +め +モ +も +ラ +ら +リ +り +ル +る +レ +れ +ロ +ろ +ヤ +や +ユ +ゆ +ヨ +よ +ワ +わ +ン +ん +ヲ +を +ッ +っ +ャ +ゃ +ュ +ゅ +ョ +ょ +ァ +ー +ィ +‥ +ぅ +! +ェ +? +ォ +% +/ +: +「 +」 +。 +A +B +X +Y +L +R +E +H +M +P +S +C +T +↑ +→ ++ +[洋剣] +[wh.mag] +[blk.mag] +🕒 +[刂] +[槍] +[鉞] +[刀] +[棒] +[杖] +[弓] +♪ +[鞭] +[bell] +[shield] +[helmet] +[armor] +[ring] + + + + + + + + + + + diff --git a/data/string_blocks.tsv b/data/string_blocks.tsv new file mode 100644 index 0000000..5c61a2a --- /dev/null +++ b/data/string_blocks.tsv @@ -0,0 +1,12 @@ +name num_entries address snes_address bytes snes_bytes rpge_ptr_offset snes_ptr_offset dialog null_terminated +ability_names 33 0x116200 8 +battle_commands 96 0x201150 0x115800 7 5 +character_names 5 0x115500 6 +dialogue 0x900 0x2013F0 0x082220 3 2 0x000000 0x0A0000 True +enemy_names 384 0x200050 0x105C00 10 8 +items 0x100 0x111380 9 +job_names 22 0x115600 8 +magics 87 0x111C80 6 +magics2 73 0x111E8A 9 +menu_strings 139 0x00F987 2 0x270000 0x000000 True +zone_names 0x100 0x107000 2 0x270000 0x107200 True \ No newline at end of file diff --git a/main_menu.tscn b/main_menu.tscn index 43a4e95..20d2fa1 100644 --- a/main_menu.tscn +++ b/main_menu.tscn @@ -4,7 +4,7 @@ [ext_resource path="res://theme/menu_theme.tres" type="Theme" id=2] [ext_resource path="res://widgets/ColorMenu.tscn" type="PackedScene" id=3] [ext_resource path="res://theme/border_imagetexture.tres" type="Texture" id=4] -[ext_resource path="res://party_menu.tscn" type="PackedScene" id=5] +[ext_resource path="res://widgets/PartyMenu.tscn" type="PackedScene" id=5] [ext_resource path="res://widgets/RomSelect.tscn" type="PackedScene" id=6] [node name="main_menu" type="Control"] @@ -58,7 +58,5 @@ From here" [node name="RomSelect" parent="." instance=ExtResource( 6 )] [node name="ColorMenu" parent="." instance=ExtResource( 3 )] -margin_left = 548.0 -margin_top = 288.0 -margin_right = 633.0 -margin_bottom = 352.0 +margin_left = 384.0 +margin_right = 469.0 diff --git a/project.godot b/project.godot index 953e301..6e86c62 100644 --- a/project.godot +++ b/project.godot @@ -22,13 +22,15 @@ config/icon="res://icon.png" [autoload] globals="*res://globals.gd" -Common="*res://scripts/loaders/common.gd" -CommonGBA="*res://scripts/loaders/common_gba.gd" -SoundLoader="*res://scripts/loaders/sound_loader.gd" -SpriteLoader="*res://scripts/loaders/sprite_loader.gd" -MapLoader="*res://scripts/loaders/map_loader.gd" -RomLoader="*res://scripts/loaders/rom_loader.gd" -SaveLoader="*res://scripts/loaders/save_loader.gd" +Common="*res://scripts/managers/Common.gd" +CommonGBA="*res://scripts/loaders/gba/common.gd" +SoundLoader="*res://scripts/loaders/SoundLoader.gd" +SpriteLoader="*res://scripts/loaders/SpriteLoader.gd" +MapLoader="*res://scripts/loaders/MapLoader.gd" +RomLoader="*res://scripts/loaders/RomLoader.gd" +SaveLoader="*res://scripts/loaders/SaveLoader.gd" +ThemeManager="*res://scripts/managers/ThemeManager.gd" +StringLoader="*res://scripts/loaders/StringLoader.gd" [debug] diff --git a/scripts/loaders/map_loader.gd b/scripts/loaders/MapLoader.gd similarity index 100% rename from scripts/loaders/map_loader.gd rename to scripts/loaders/MapLoader.gd diff --git a/scripts/loaders/rom_loader.gd b/scripts/loaders/RomLoader.gd similarity index 97% rename from scripts/loaders/rom_loader.gd rename to scripts/loaders/RomLoader.gd index af6430e..be2af51 100644 --- a/scripts/loaders/rom_loader.gd +++ b/scripts/loaders/RomLoader.gd @@ -20,6 +20,7 @@ func load_snes_rom(filename: String): if error == OK: SpriteLoader.load_snes_rom(rom_snes) MapLoader.load_snes_rom(rom_snes) + StringLoader.load_snes_rom(rom_snes, true) var _thread_error = thread.start(SoundLoader, 'parse_rom', rom_snes) func load_psx_folder(_dirname: String): diff --git a/scripts/loaders/save_loader.gd b/scripts/loaders/SaveLoader.gd similarity index 93% rename from scripts/loaders/save_loader.gd rename to scripts/loaders/SaveLoader.gd index 4fab5e1..21a01b3 100644 --- a/scripts/loaders/save_loader.gd +++ b/scripts/loaders/SaveLoader.gd @@ -57,6 +57,12 @@ func put_struct(buffer: StreamPeer, struct_name: String, data: Dictionary): func deserialize_save_slot(buffer: StreamPeerBuffer) -> Dictionary: return struct_types['Save_slot'].get_value(buffer, [0, 0]) +func load_save_slot(buffer: StreamPeerBuffer) -> Dictionary: + # Like deserialize_save_slot, but also decodes strings and maybe other postprocessing later + var data = deserialize_save_slot(buffer) + data.character_names_decoded = StringLoader.decode_array(data.character_names, 'RPGe_small') + return data + func serialize_save_slot(data: Dictionary) -> StreamPeerBuffer: var buffer := StreamPeerBuffer.new() struct_types['Save_slot'].put_value(buffer, data, [0, 0]) diff --git a/scripts/loaders/sound_loader.gd b/scripts/loaders/SoundLoader.gd similarity index 100% rename from scripts/loaders/sound_loader.gd rename to scripts/loaders/SoundLoader.gd diff --git a/scripts/loaders/sprite_loader.gd b/scripts/loaders/SpriteLoader.gd similarity index 100% rename from scripts/loaders/sprite_loader.gd rename to scripts/loaders/SpriteLoader.gd diff --git a/scripts/loaders/StringLoader.gd b/scripts/loaders/StringLoader.gd new file mode 100644 index 0000000..91a8b4b --- /dev/null +++ b/scripts/loaders/StringLoader.gd @@ -0,0 +1,97 @@ +extends Node + +var SNES_block_addresses := Common.load_tsv('res://data/string_blocks.tsv') +var tables_raw = {} +var tables = {} + +var glyph_tables := { + 'RPGe_dialog': Common.load_glyph_table('res://data/glyph_tables/Glyphs_dialog_RPGe.txt'), + 'RPGe_small': Common.load_glyph_table('res://data/glyph_tables/Glyphs_small_RPGe.txt'), + 'SNES_dialog': Common.load_glyph_table('res://data/glyph_tables/Glyphs_dialog_SNES.txt'), + 'SNES_kanji': Common.load_glyph_table('res://data/glyph_tables/Glyphs_dialog_kanji_SNES.txt'), + 'SNES_small': Common.load_glyph_table('res://data/glyph_tables/Glyphs_small_SNES.txt'), +} + +static func decode_string(bytes, glyph_table: PoolStringArray, trim_trailing_whitespace: bool = true) -> String: + # Trivial conversion for small text + # Dialog requires multibyte handling including kanji and other macros + var output = '' + for c in bytes: + output += glyph_table[c] + return output.trim_suffix(' ') if trim_trailing_whitespace else output + +func decode_array(array, glyph_table, trim_trailing_whitespace: bool = true) -> PoolStringArray: + if glyph_table is String: + glyph_table = glyph_tables[glyph_table] + var output = PoolStringArray() + for s in array: + output.append(decode_string(s, glyph_table, trim_trailing_whitespace)) + return output + +func load_snes_rom(rom: File, is_RPGe: bool = false) -> void: + for block_name in SNES_block_addresses: + var block: Dictionary = SNES_block_addresses[block_name] + var glyph_table_small: PoolStringArray = glyph_tables.RPGe_small if is_RPGe else glyph_tables.SNES_small + var raw_strings := [] + var strings := PoolStringArray() + var num_entries: int = block.num_entries + var l1_width: int = block.bytes + if (not is_RPGe) and block.snes_bytes: + l1_width = block.snes_bytes + var l1_address: int = block.address + if (not is_RPGe) and block.snes_address: + l1_address = block.snes_address + rom.seek(l1_address) + + var ptr_offset = block.rpge_ptr_offset if is_RPGe else block.snes_ptr_offset + if ptr_offset is int: + var ptrs = PoolIntArray() + match l1_width: + 1: + for i in num_entries: + ptrs.append((ptr_offset + rom.get_8()) & 0x3FFFFF) # Bank wrapping + 2: + for i in num_entries: + ptrs.append((ptr_offset + rom.get_16()) & 0x3FFFFF) # Bank wrapping + 3: + for i in num_entries: + ptrs.append((ptr_offset + rom.get_16() + (rom.get_8() << 16)) & 0x3FFFFF) # Bank wrapping + _: + assert(false, 'Indirect l1_width of %d is not possible' % l1_width) + if block.null_terminated: + for i in num_entries: + rom.seek(ptrs[i]) + var bytes = PoolByteArray() + while true: + var b = rom.get_8() + if b == 0: + break + bytes.append(b) + raw_strings.append(bytes) + else: + for i in num_entries-1: + rom.seek(ptrs[i]) + raw_strings.append(rom.get_buffer(ptrs[i+1] - ptrs[i])) + else: + # Get first level of data + for i in num_entries: + raw_strings.append(rom.get_buffer(l1_width)) + + # Decode + if block.dialog: + pass # TODO + else: + for raw in raw_strings: + strings.append(decode_string(raw, glyph_table_small)) + tables_raw[block_name] = raw_strings + tables[block_name] = strings + +func get_ability_name(id: int) -> String: + var l = 128 + if id < l: + return tables.battle_commands[id] + else: + return tables.ability_names[id-l] + +func _ready() -> void: + pass diff --git a/scripts/loaders/common_gba.gd b/scripts/loaders/gba/common.gd similarity index 100% rename from scripts/loaders/common_gba.gd rename to scripts/loaders/gba/common.gd diff --git a/scripts/loaders/common.gd b/scripts/managers/Common.gd similarity index 82% rename from scripts/loaders/common.gd rename to scripts/managers/Common.gd index a7c2db2..7c44b69 100644 --- a/scripts/loaders/common.gd +++ b/scripts/managers/Common.gd @@ -4,6 +4,16 @@ var base_resolution: Vector2 = Vector2(ProjectSettings.get_setting('display/wind var shrink_timer := Timer.new() var last_resolution_pre_shrink := Vector2.ZERO +var SNES_PSX_addresses := load_tsv('res://data/SNES_PSX_addresses.tsv') + +static func eval(expression: String): + var ex = Expression.new() + match ex.parse(expression): + OK: + return ex.execute() + var error: + print_debug(ex.get_error_text(), error) + static func load_json(filename: String): # Valid JSON will return Array or Dictionary. int error code for anything else. var file := File.new() match file.open(filename, File.READ): @@ -49,6 +59,18 @@ static func save_json(filename: String, data) -> int: # Returns error code but file.store_line(_to_json(data, 0)) return OK +static func load_glyph_table(filename: String) -> PoolStringArray: + var output = PoolStringArray() + var file = File.new() + match file.open(filename, File.READ): + OK: + var l: int = file.get_len() + while file.get_position() < l: + output.append(file.get_line()) + var error: + print_debug('Failed to open glyph table "%s" - %d' % [filename, error]) + return output + static func genericize_type(type: int) -> int: match type: TYPE_RAW_ARRAY, TYPE_INT_ARRAY, TYPE_REAL_ARRAY, TYPE_STRING_ARRAY: @@ -103,6 +125,28 @@ static func are_arrays_equal(a1: Array, a2: Array, fuzzy_types: bool = true) -> return false return true +static func limited_eval(token: String): + # Try hexadecimal literal + if token.begins_with('0x'): + var hex := token.hex_to_int() + if hex > 0: + return hex + # Try int literal + if token.is_valid_integer(): + return int(token) + # Try float literal + if token.is_valid_float(): + return float(token) + # Try bool literal + match token.to_lower(): + 'true': + return true + 'false': + return false + # It's just a string + return token + + static func load_tsv(filename: String, delimiter: String = '\t') -> Dictionary: var file := File.new() var error := file.open(filename, File.READ) @@ -115,19 +159,12 @@ static func load_tsv(filename: String, delimiter: String = '\t') -> Dictionary: var entry := {} for i in range(1, n): if line.size() > i: - var token := line[i] - entry[headers[i]] = token - if token.begins_with('0x'): - var hex := token.hex_to_int() - if hex > 0: - entry[headers[i]] = hex + entry[headers[i]] = limited_eval(line[i]) output[line[0]] = entry return output print_debug(error) return {} -var SNES_PSX_addresses := load_tsv('res://data/SNES_PSX_addresses.tsv') - func shrink_to_integer(): var size := OS.get_window_size() var scale_vec := size / base_resolution @@ -160,6 +197,12 @@ func update_window_scale(): shrink_timer.start(1) get_tree().set_screen_stretch(SceneTree.STRETCH_MODE_VIEWPORT, SceneTree.STRETCH_ASPECT_KEEP, base_resolution*scale, scale) +static func game_time_frames_to_hhmm(game_time_frames: int) -> String: + var game_seconds = game_time_frames / 60 + var game_minutes = game_seconds / 60 + var game_hours = game_minutes / 60 + return '%d:%02d' % [game_hours, game_minutes % 60] + func _ready(): shrink_timer.connect('timeout', self, 'shrink_to_integer') shrink_timer.one_shot = true diff --git a/scripts/managers/ThemeManager.gd b/scripts/managers/ThemeManager.gd new file mode 100644 index 0000000..afde5b2 --- /dev/null +++ b/scripts/managers/ThemeManager.gd @@ -0,0 +1,33 @@ +extends Node +var menu_r5 := 0 +var menu_g5 := 0 +var menu_b5 := 16 + +var border_image: Image = preload('res://theme/border.png') +var border_texture := preload('res://theme/border_imagetexture.tres') +var border_stylebox := preload('res://theme/border_stylebox.tres') +const r1 := Rect2(4, 3, 2, 4) +const r2 := Rect2(3, 4, 4, 2) + +func update_menu_color() -> void: + var c := Color(menu_r5/31.0, menu_g5/31.0, menu_b5/31.0) + # print(c) + border_image.fill_rect(r1, c) + border_image.fill_rect(r2, c) + border_texture.set_data(border_image) + +func set_menu_color_555(r5: int, g5: int, b5: int) -> void: + self.menu_r5 = r5 + self.menu_g5 = g5 + self.menu_b5 = b5 + self.update_configuration_warning() + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + border_texture.create_from_image(border_image, 0) + self.update_menu_color() + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +#func _process(delta: float) -> void: +# pass diff --git a/scripts/struct.gd b/scripts/struct.gd index f75da2e..60415b9 100644 --- a/scripts/struct.gd +++ b/scripts/struct.gd @@ -191,7 +191,8 @@ static func get_structarraytype(type: String, existing_structs: Dictionary): static func parse_struct_definitions_from_tsv_file(tsv_file: File, existing_structs: Dictionary) -> void: var current_struct: Struct var line_num := 0 # Currently only used for step-through debugging - while tsv_file.get_position() < tsv_file.get_len(): + var l := tsv_file.get_len() + while tsv_file.get_position() < l: var line := tsv_file.get_csv_line('\t') line_num += 1 var size = line.size() diff --git a/test_scene.gd b/test_scene.gd index 9c3113d..4affd32 100644 --- a/test_scene.gd +++ b/test_scene.gd @@ -1,4 +1,4 @@ -extends Node2D +extends Control var save_slots = [] var save_slot_dicts = [] @@ -10,7 +10,7 @@ func _ready(): if error == OK: for i in 4: save_slots.append(SaveLoader.get_save_slot(save_file, i)) - save_slot_dicts.append(SaveLoader.get_struct(save_slots[i], 'Save_slot')) + save_slot_dicts.append(SaveLoader.load_save_slot(save_slots[i])) print('Loaded test save file') save_file.close() # error = save_file.open('downloaded_saves/psx_world1.gme', File.READ) @@ -19,3 +19,4 @@ func _ready(): # save_file.seek(0x2FA0) # buffer.data_array = save_file.get_buffer(0x600) # save_slot_dicts.append(SaveLoader.get_struct(buffer, 'Save_slot')) + $PartyMenu.update_labels(save_slot_dicts[0]) diff --git a/test_scene.tscn b/test_scene.tscn index 2a67544..afcc8b0 100644 --- a/test_scene.tscn +++ b/test_scene.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=7 format=2] -[ext_resource path="res://palette_mat.tres" type="Material" id=1] +[ext_resource path="res://widgets/PartyMenu.tscn" type="PackedScene" id=1] [ext_resource path="res://test/worldmap_system.tscn" type="PackedScene" id=2] [ext_resource path="res://test_scene.gd" type="Script" id=3] [ext_resource path="res://test/battle_sprites.tscn" type="PackedScene" id=4] @@ -11,15 +11,16 @@ anchor_right = 1.0 anchor_bottom = 1.0 theme = ExtResource( 6 ) - -[node name="Node2D" type="Node2D" parent="."] -material = ExtResource( 1 ) -position = Vector2( 16, 16 ) script = ExtResource( 3 ) [node name="audio_system" parent="." instance=ExtResource( 5 )] -position = Vector2( 0, 400 ) +visible = false +position = Vector2( 0, 160 ) [node name="worldmap_system" parent="." instance=ExtResource( 2 )] +visible = false [node name="battle_sprites" parent="." instance=ExtResource( 4 )] +visible = false + +[node name="PartyMenu" parent="." instance=ExtResource( 1 )] diff --git a/widgets/ColorMenu.gd b/widgets/ColorMenu.gd index 9e85adb..65934ac 100644 --- a/widgets/ColorMenu.gd +++ b/widgets/ColorMenu.gd @@ -3,24 +3,11 @@ var r := 0 var g := 0 var b := 16 -var border_image: Image = preload('res://theme/border.png') -var border_texture := preload('res://theme/border_imagetexture.tres') -var border_stylebox := preload('res://theme/border_stylebox.tres') -const r1 := Rect2(4, 3, 2, 4) -const r2 := Rect2(3, 4, 4, 2) - func update_menu_color() -> void: - var c := Color(r/31.0, g/31.0, b/31.0) - # print(c) $label_nums.text = '\n%d\n%d\n%d' % [r, g, b] - border_image.fill_rect(r1, c) - border_image.fill_rect(r2, c) - border_texture.set_data(border_image) - # border_stylebox.texture = border_texture - # update() + ThemeManager.set_menu_color_555(r, g, b) func _ready() -> void: - border_texture.create_from_image(border_image, 0) $slider_r.value = r $slider_g.value = g $slider_b.value = b diff --git a/widgets/PartyMenu.gd b/widgets/PartyMenu.gd new file mode 100644 index 0000000..08b558b --- /dev/null +++ b/widgets/PartyMenu.gd @@ -0,0 +1,21 @@ +extends Panel + +func update_labels(data: Dictionary): + var characters = data.characters + var character_panels = $characters.get_children() + for i in len(characters): + var p = character_panels[i] + p.visible = not characters[i].is_absent + p.update_labels(data, i) + + $rightside/panel_time/VBoxContainer/lbl_time.text = Common.game_time_frames_to_hhmm(data.game_time_frames) + $rightside/panel_gil/VBoxContainer/lbl_gilcount.text = '%d' % data.current_gil + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +#func _process(delta: float) -> void: +# pass diff --git a/party_menu.tscn b/widgets/PartyMenu.tscn similarity index 89% rename from party_menu.tscn rename to widgets/PartyMenu.tscn index 319d21f..5c37063 100644 --- a/party_menu.tscn +++ b/widgets/PartyMenu.tscn @@ -1,12 +1,14 @@ -[gd_scene load_steps=3 format=2] +[gd_scene load_steps=4 format=2] [ext_resource path="res://theme/menu_theme.tres" type="Theme" id=1] -[ext_resource path="res://widgets/PartyMenuCharacter.tscn" type="PackedScene" id=2] +[ext_resource path="res://widgets/PartyMenu.gd" type="Script" id=2] +[ext_resource path="res://widgets/PartyMenuCharacter.tscn" type="PackedScene" id=3] -[node name="Panel" type="Panel"] +[node name="PartyMenu" type="Panel"] margin_right = 264.0 margin_bottom = 240.0 theme = ExtResource( 1 ) +script = ExtResource( 2 ) [node name="characters" type="VBoxContainer" parent="."] anchor_right = 1.0 @@ -16,18 +18,22 @@ margin_top = 8.0 margin_right = -8.0 margin_bottom = -8.0 -[node name="PartyMenuCharacter" parent="characters" instance=ExtResource( 2 )] +[node name="PartyMenuCharacter" parent="characters" instance=ExtResource( 3 )] +margin_right = 240.0 -[node name="PartyMenuCharacter2" parent="characters" instance=ExtResource( 2 )] +[node name="PartyMenuCharacter2" parent="characters" instance=ExtResource( 3 )] margin_top = 58.0 +margin_right = 240.0 margin_bottom = 108.0 -[node name="PartyMenuCharacter3" parent="characters" instance=ExtResource( 2 )] +[node name="PartyMenuCharacter3" parent="characters" instance=ExtResource( 3 )] margin_top = 116.0 +margin_right = 240.0 margin_bottom = 166.0 -[node name="PartyMenuCharacter4" parent="characters" instance=ExtResource( 2 )] +[node name="PartyMenuCharacter4" parent="characters" instance=ExtResource( 3 )] margin_top = 174.0 +margin_right = 240.0 margin_bottom = 224.0 [node name="rightside" type="VBoxContainer" parent="."] @@ -136,16 +142,16 @@ margin_right = 60.0 margin_bottom = 32.0 custom_constants/separation = 0 -[node name="lbl_time" type="Label" parent="rightside/panel_time/VBoxContainer"] +[node name="TIME" type="Label" parent="rightside/panel_time/VBoxContainer"] margin_right = 56.0 margin_bottom = 14.0 text = "Time" -[node name="lbl_ability" type="Label" parent="rightside/panel_time/VBoxContainer"] +[node name="lbl_time" type="Label" parent="rightside/panel_time/VBoxContainer"] margin_top = 14.0 margin_right = 56.0 margin_bottom = 28.0 -text = "9:42" +text = "0:00" align = 2 [node name="panel_gil" type="PanelContainer" parent="rightside"] @@ -164,10 +170,10 @@ custom_constants/separation = 0 [node name="lbl_gilcount" type="Label" parent="rightside/panel_gil/VBoxContainer"] margin_right = 64.0 margin_bottom = 14.0 -text = "36988" +text = "0" align = 2 -[node name="lbl_gil" type="Label" parent="rightside/panel_gil/VBoxContainer"] +[node name="GIL" type="Label" parent="rightside/panel_gil/VBoxContainer"] margin_top = 14.0 margin_right = 64.0 margin_bottom = 28.0 diff --git a/widgets/PartyMenuCharacter.gd b/widgets/PartyMenuCharacter.gd index 155de4a..35ed0e0 100644 --- a/widgets/PartyMenuCharacter.gd +++ b/widgets/PartyMenuCharacter.gd @@ -1,24 +1,38 @@ extends ReferenceRect -func update_labels(data: Dictionary): - var character = data.character_id - $lbl_lv_cur.text = data.level - $lbl_abp_lv_cur.text = data.current_job_level + '-' - $lbl_abp_progress.text = data.current_job_abp + '/' - $lbl_abp_next.text = data.current_job_abp # Revisit - $lbl_hp_cur.text = data.hp_current + '/' - $lbl_hp_max.text = data.hp_max - $lbl_mp_cur.text = data.mp_current + '/' - $lbl_mp_max.text = data.mp_max - $lbl_lv_cur.text = data.level +onready var rect_frontrow := Rect2($ref0/ref_frontrow.rect_position, $ref0/ref_frontrow.rect_size) +onready var rect_backrow := Rect2($ref0/ref_backrow.rect_position, $ref0/ref_backrow.rect_size) +onready var row_rects := [rect_frontrow, rect_backrow] + +func update_labels(data: Dictionary, i: int): + var c = data.characters[i] + var character = c.character_id + var job = c.current_job_id + var cj_idx = character*22 + job + $ref0/lbl_name.text = data.character_names_decoded[character] + $ref0/lbl_lv_cur.text = '%d' % c.level + $ref1/lbl_job.text = StringLoader.tables.job_names[job] + $ref1/lbl_abp_lv_cur.text = '%d-' % c.current_job_level + $ref1/lbl_abp_progress.text = '%d/' % c.current_job_abp + $ref1/lbl_abp_next.text = '%d' % c.current_job_abp # Revisit + $ref1/lbl_hp_cur.text = '%d/' % c.hp_current + $ref1/lbl_hp_max.text = '%d' % c.hp_max + $ref1/lbl_mp_cur.text = '%d/' % c.mp_current + $ref1/lbl_mp_max.text = '%d' % c.mp_max + $'ref_commands/1'.text = StringLoader.get_ability_name(c.ability_1) + $'ref_commands/2'.text = StringLoader.get_ability_name(c.ability_2) + $'ref_commands/3'.text = StringLoader.get_ability_name(c.ability_3) + $'ref_commands/4'.text = StringLoader.get_ability_name(c.ability_4) # Draw character battle sprite in either ref_frontrow or ref_backrow - # THink about status icons + $ref0/PC.position = row_rects[c.is_back_row].position + $ref0/PC.material.set_shader_param('palette', SpriteLoader.character_battle_sprite_palette_textures[cj_idx]) + $ref0/PC.texture = SpriteLoader.strip_textures[cj_idx] + # Think about status icons # Called when the node enters the scene tree for the first time. func _ready() -> void: pass # Replace with function body. - # Called every frame. 'delta' is the elapsed time since the previous frame. #func _process(delta: float) -> void: # pass diff --git a/widgets/PartyMenuCharacter.tscn b/widgets/PartyMenuCharacter.tscn index 0d60f97..6b4e6ff 100644 --- a/widgets/PartyMenuCharacter.tscn +++ b/widgets/PartyMenuCharacter.tscn @@ -1,34 +1,124 @@ -[gd_scene load_steps=2 format=2] +[gd_scene load_steps=3 format=2] [ext_resource path="res://widgets/PartyMenuCharacter.gd" type="Script" id=1] +[ext_resource path="res://PC.tscn" type="PackedScene" id=2] [node name="PartyMenuCharacter" type="ReferenceRect"] margin_right = 180.0 margin_bottom = 50.0 -rect_min_size = Vector2( 180, 50 ) +rect_min_size = Vector2( 240, 50 ) size_flags_horizontal = 0 size_flags_vertical = 0 script = ExtResource( 1 ) -[node name="lbl_name" type="Label" parent="."] -margin_right = 40.0 -margin_bottom = 14.0 -text = "Butz" +[node name="ref1" type="ReferenceRect" parent="."] +margin_left = 56.0 +margin_right = 160.0 +margin_bottom = 50.0 +border_color = Color( 0, 0, 1, 1 ) -[node name="lbl_job" type="Label" parent="."] -margin_left = 72.0 -margin_right = 144.0 +[node name="lbl_job" type="Label" parent="ref1"] +margin_right = 72.0 margin_bottom = 14.0 text = "Freelancer" -[node name="LV" type="Label" parent="."] +[node name="abp_LV" type="Label" parent="ref1"] margin_left = 8.0 margin_top = 12.0 margin_right = 23.0 margin_bottom = 26.0 text = "LV" -[node name="lbl_lv_cur" type="Label" parent="."] +[node name="lbl_abp_lv_cur" type="Label" parent="ref1"] +margin_left = 24.0 +margin_top = 12.0 +margin_right = 48.0 +margin_bottom = 26.0 +text = "2-" +align = 2 + +[node name="lbl_abp_progress" type="Label" parent="ref1"] +margin_left = 36.0 +margin_top = 12.0 +margin_right = 80.0 +margin_bottom = 26.0 +text = "76/" +align = 2 + +[node name="lbl_abp_next" type="Label" parent="ref1"] +margin_left = 60.0 +margin_top = 12.0 +margin_right = 104.0 +margin_bottom = 26.0 +text = "135" +align = 2 + +[node name="HP" type="Label" parent="ref1"] +margin_left = 8.0 +margin_top = 25.0 +margin_right = 32.0 +margin_bottom = 39.0 +rect_min_size = Vector2( 24, 0 ) +text = "HP" + +[node name="lbl_hp_cur" type="Label" parent="ref1"] +margin_left = 32.0 +margin_top = 25.0 +margin_right = 72.0 +margin_bottom = 39.0 +rect_min_size = Vector2( 40, 0 ) +text = "9999/" +align = 2 + +[node name="lbl_hp_max" type="Label" parent="ref1"] +margin_left = 72.0 +margin_top = 25.0 +margin_right = 104.0 +margin_bottom = 39.0 +rect_min_size = Vector2( 32, 0 ) +text = "9999" +align = 2 + +[node name="MP" type="Label" parent="ref1"] +margin_left = 8.0 +margin_top = 36.0 +margin_right = 32.0 +margin_bottom = 50.0 +text = "MP" + +[node name="lbl_mp_cur" type="Label" parent="ref1"] +margin_left = 32.0 +margin_top = 36.0 +margin_right = 72.0 +margin_bottom = 50.0 +text = "999/" +align = 2 + +[node name="lbl_mp_max" type="Label" parent="ref1"] +margin_left = 72.0 +margin_top = 36.0 +margin_right = 104.0 +margin_bottom = 50.0 +text = "999" +align = 2 + +[node name="ref0" type="ReferenceRect" parent="."] +margin_right = 56.0 +margin_bottom = 50.0 + +[node name="lbl_name" type="Label" parent="ref0"] +margin_right = 40.0 +margin_bottom = 14.0 +text = "Butz" + +[node name="LV" type="Label" parent="ref0"] +margin_left = 8.0 +margin_top = 12.0 +margin_right = 23.0 +margin_bottom = 26.0 +text = "LV" + +[node name="lbl_lv_cur" type="Label" parent="ref0"] margin_left = 32.0 margin_top = 12.0 margin_right = 56.0 @@ -36,38 +126,7 @@ margin_bottom = 26.0 text = "26" align = 2 -[node name="abp_LV" type="Label" parent="."] -margin_left = 84.0 -margin_top = 12.0 -margin_right = 99.0 -margin_bottom = 26.0 -text = "LV" - -[node name="lbl_abp_lv_cur" type="Label" parent="."] -margin_left = 100.0 -margin_top = 12.0 -margin_right = 124.0 -margin_bottom = 26.0 -text = "2-" -align = 2 - -[node name="lbl_abp_progress" type="Label" parent="."] -margin_left = 112.0 -margin_top = 12.0 -margin_right = 156.0 -margin_bottom = 26.0 -text = "76/" -align = 2 - -[node name="lbl_abp_next" type="Label" parent="."] -margin_left = 136.0 -margin_top = 12.0 -margin_right = 180.0 -margin_bottom = 26.0 -text = "135" -align = 2 - -[node name="ref_frontrow" type="ReferenceRect" parent="."] +[node name="ref_frontrow" type="ReferenceRect" parent="ref0"] anchor_top = 1.0 anchor_bottom = 1.0 margin_left = 8.0 @@ -75,7 +134,7 @@ margin_top = -24.0 margin_right = 24.0 border_color = Color( 1, 0.501961, 0, 1 ) -[node name="ref_backrow" type="ReferenceRect" parent="."] +[node name="ref_backrow" type="ReferenceRect" parent="ref0"] anchor_top = 1.0 anchor_bottom = 1.0 margin_left = 40.0 @@ -83,51 +142,32 @@ margin_top = -24.0 margin_right = 56.0 border_color = Color( 0, 1, 0, 1 ) -[node name="HP" type="Label" parent="."] -margin_left = 84.0 -margin_top = 25.0 -margin_right = 108.0 -margin_bottom = 39.0 -rect_min_size = Vector2( 24, 0 ) -text = "HP" +[node name="PC" parent="ref0" instance=ExtResource( 2 )] -[node name="lbl_hp_cur" type="Label" parent="."] -margin_left = 108.0 -margin_top = 25.0 -margin_right = 148.0 -margin_bottom = 39.0 -rect_min_size = Vector2( 40, 0 ) -text = "9999/" -align = 2 - -[node name="lbl_hp_max" type="Label" parent="."] -margin_left = 148.0 -margin_top = 25.0 -margin_right = 180.0 -margin_bottom = 39.0 -rect_min_size = Vector2( 32, 0 ) -text = "9999" -align = 2 - -[node name="MP" type="Label" parent="."] -margin_left = 84.0 -margin_top = 36.0 -margin_right = 108.0 +[node name="ref_commands" type="ReferenceRect" parent="."] +margin_left = 168.0 +margin_right = 240.0 margin_bottom = 50.0 -text = "MP" -[node name="lbl_mp_cur" type="Label" parent="."] -margin_left = 108.0 -margin_top = 36.0 -margin_right = 148.0 -margin_bottom = 50.0 -text = "999/" -align = 2 +[node name="1" type="Label" parent="ref_commands"] +margin_right = 72.0 +margin_bottom = 14.0 +text = "Fight" -[node name="lbl_mp_max" type="Label" parent="."] -margin_left = 148.0 +[node name="2" type="Label" parent="ref_commands"] +margin_top = 12.0 +margin_right = 72.0 +margin_bottom = 26.0 +text = "Guard" + +[node name="3" type="Label" parent="ref_commands"] +margin_top = 24.0 +margin_right = 72.0 +margin_bottom = 38.0 +text = "DragnSwd" + +[node name="4" type="Label" parent="ref_commands"] margin_top = 36.0 -margin_right = 180.0 +margin_right = 72.0 margin_bottom = 50.0 -text = "999" -align = 2 +text = "Item" diff --git a/widgets/SaveSlot.gd b/widgets/SaveSlot.gd index 9be72fe..7b8e3b6 100644 --- a/widgets/SaveSlot.gd +++ b/widgets/SaveSlot.gd @@ -32,10 +32,7 @@ func set_data(data: Dictionary): PCs[i].material.set_shader_param('palette', SpriteLoader.character_battle_sprite_palette_textures[sprite_id]) PCs[i].texture = SpriteLoader.strip_textures[sprite_id] $HBoxContainer/right_labels/HBoxContainer/lbl_level_num.text = '%d' % data.characters[0].level - var game_seconds = data.game_time_frames / 60 - var game_minutes = game_seconds / 60 - var game_hours = game_minutes / 60 - $HBoxContainer/left_labels/lbl_gametime.text = '%d:%02d' % [game_hours, game_minutes % 60] + $HBoxContainer/left_labels/lbl_gametime.text = Common.game_time_frames_to_hhmm(data.game_time_frames) $HBoxContainer/left_labels/lbl_name.text = data.character_names[data.characters[0].character_id] $HBoxContainer/right_labels/lbl_hp.text = '%d/%4d' % [data.characters[0].hp_current, data.characters[0].hp_max]