DEFINE_ACTION_FUNCTION ~LOOTPANEL~ INT_VAR option = 0 BEGIN ACTION_IF (MOD_IS_INSTALLED ~Setup-TutuGUI.tp2~ 0) THEN BEGIN OUTER_SET TutuGUI=1 PRINT ~Found TutuGUI~ COPY ~bg2improvedgui/loot_panel/files/TutuGUI/GMPWMSGB.MOS~ ~override~ COPY ~bg2improvedgui/loot_panel/files/TutuGUI/GMPWMSG8.MOS~ ~override~ COPY ~bg2improvedgui/loot_panel/files/TutuGUI/GMPWMSG0.MOS~ ~override~ END ELSE BEGIN OUTER_SET TutuGUI=0 COPY ~bg2improvedgui/loot_panel/files/GUICONTB.MOS~ ~override~ ~bg2improvedgui/loot_panel/files/GMPWMSG8.MOS~ ~override~ ~bg2improvedgui/loot_panel/files/GMPWMSG0.MOS~ ~override~ END ACTION_IF (MOD_IS_INSTALLED ~Setup-GUI_720.tp2~ 0) THEN BEGIN OUTER_SET GUI_720=1 PRINT ~Found BG2 GUI 1280x720~ COPY ~bg2improvedgui/loot_panel/files/GUI_720/GMPWMSG8.MOS~ ~override~ COPY "TobEx_ini/TobExTweak.ini" "TobEx_ini/TobExTweak.ini" APPEND_FILE "bg2improvedgui/loot_panel/files/GUI_720/TobEx.txt" BUT_ONLY END ELSE BEGIN OUTER_SET GUI_720=0 END COPY_EXISTING ~guiw.chu~ ~override~ ~guiw08.chu~ ~override~ ~guiw10.chu~ ~override~ // code based on TobEx0018.tpa (c)Ascension64 SET Panel_Y_Diff = 135 - 90 SET StartX = 64 + 1 SET StartY = 9 PATCH_IF (TutuGUI = 1) BEGIN StartY = 6 // TutuGUI END SET StartButtonID = 14 SET ScrollButtonWidth = 19 SET ScrollButtonHeight = 19 SET need_mos_enlarge = 0 READ_LONG 0x8 nPanels READ_LONG 0xc offControlTbl READ_LONG 0x10 offPanels SET i = 0 SET nControls = 0 SET ContainerPanelNum = 0 FOR (i = 0; i < nPanels; i+= 1) BEGIN READ_SHORT (%offPanels% + %i% * 0x1c + 0xe) nPanelControls READ_SHORT (%offPanels% + %i% * 0x1c + 0x0) PanelID PATCH_IF (PanelID = 8) BEGIN ContainerPanelNum = i READ_SHORT (%offPanels% + %i% * 0x1c + 0x6) Panel_Y WRITE_SHORT (%offPanels% + %i% * 0x1c + 0x6) (Panel_Y - Panel_Y_Diff) READ_SHORT (%offPanels% + %i% * 0x1c + 0x8) PanelWidth READ_SHORT (%offPanels% + %i% * 0x1c + 0xA) PanelHeight WRITE_SHORT (%offPanels% + %i% * 0x1c + 0xA) (PanelHeight + Panel_Y_Diff) //WRITE_ASCII (%offPanels% + %i% * 0x1c + 0x10) "GUICONTB" #8 // BAM END SET nControls += nPanelControls END // Shift all Control Y-Coors down to Y + Panel_Y_Diff READ_SHORT (%offPanels% + %ContainerPanelNum% * 0x1c + 0xe) nContainerPanelControls READ_SHORT (%offPanels% + %ContainerPanelNum% * 0x1c + 0x18) idxPanelControl FOR (i = 0; i < nContainerPanelControls; i+= 1) BEGIN READ_LONG (%offControlTbl% + (%idxPanelControl% + %i%) * 0x8) offControlThis READ_SHORT (%offControlThis% + 0x6) Y WRITE_SHORT (%offControlThis% + 0x6) (Y + Panel_Y_Diff) END PATCH_IF ("%SOURCE_FILE%" STRING_COMPARE_CASE "guiw.chu" = 0) BEGIN // Container Panel 640x480 // 6 [14 15 16 17 18 19 20 21 22 23 24] 7 SET LastButtonID = 24 SET EndX = (640 - 64) - 1 SET ScreenY = 480 SET ScrollGap = 23 END PATCH_IF ("%SOURCE_FILE%" STRING_COMPARE_CASE "guiw08.chu" = 0) BEGIN // Container Panel 800x600 // 6 [14 15 16 17 18 19 20 21 22 23 24 25 26 27] 7 SET LastButtonID = 27 SET EndX = (800 - 64) - 1 SET ScreenY = 600 SET ScrollGap = 37 END PATCH_IF ("%SOURCE_FILE%" STRING_COMPARE_CASE "guiw10.chu" = 0) BEGIN PATCH_IF ((PanelWidth >= 640) AND (PanelWidth < 800)) BEGIN // Container Panel 640x480 // 6 [14 15 16 17 18 19 20 21 22 23 24] 7 PATCH_PRINT ~Found Widescreen Mod patched guiw10.chu %PanelWidth%x%PanelHeight%~ SET LastButtonID = 24 SET EndX = (640 - 64) - 1 SET ScreenY = 480 SET ScrollGap = 23 PATCH_IF (PanelWidth != 640) BEGIN StartX = StartX + (PanelWidth - 640)/2 // centering EndX = EndX + (PanelWidth - 640)/2 need_mos_enlarge = 1 END PATCH_IF (TutuGUI = 1) BEGIN TEXT_SPRINT MOSNAME "GMPWMSGB.MOS" // TutuGUI TEXT_SPRINT HMode "H150" END ELSE BEGIN TEXT_SPRINT MOSNAME "GUICONTB.MOS" TEXT_SPRINT HMode "H300" END SET NewBackgroundWidth = PanelWidth END PATCH_IF ((PanelWidth >= 800) AND (PanelWidth < 1024)) BEGIN // Container Panel 800x600 // 6 [14 15 16 17 18 19 20 21 22 23 24 25 26 27] 7 PATCH_PRINT ~Found Widescreen Mod patched guiw10.chu %PanelWidth%x%PanelHeight%~ SET LastButtonID = 27 SET EndX = (800 - 64) - 1 SET ScreenY = 600 SET ScrollGap = 37 PATCH_IF (PanelWidth != 800) BEGIN StartX = StartX + (PanelWidth - 800)/2 // centering EndX = EndX + (PanelWidth - 800)/2 need_mos_enlarge = 1 END PATCH_IF (Panel_Y >= 500) BEGIN // Y >= 600 TEXT_SPRINT MOSNAME "GMPWMSG8.MOS" PATCH_IF (TutuGUI = 1) BEGIN TEXT_SPRINT HMode "H250" END ELSE BEGIN TEXT_SPRINT HMode "H390" END END ELSE // Y < 600 PATCH_IF (TutuGUI = 1) BEGIN TEXT_SPRINT MOSNAME "GMPWMSGB.MOS" // TutuGUI TEXT_SPRINT HMode "H150" END ELSE BEGIN TEXT_SPRINT MOSNAME "GUICONTB.MOS" TEXT_SPRINT HMode "H300" END SET NewBackgroundWidth = PanelWidth END PATCH_IF (PanelWidth >= 1024) BEGIN // Container Panel 1024x768 // 6 [14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33] 7 SET LastButtonID = 33 SET EndX = (1024 - 64) - 1 SET ScreenY = 768 SET ScrollGap = 26 PATCH_IF (PanelWidth != 1024) BEGIN StartX = StartX + (PanelWidth - 1024)/2 // centering EndX = EndX + (PanelWidth - 1024)/2 PATCH_PRINT ~Found Widescreen Mod patched guiw10.chu %PanelWidth%x%PanelHeight%~ need_mos_enlarge = 1 END PATCH_IF (GUI_720 = 1) BEGIN // Container Panel 1280x720, usable ~800x720 // 6 [14 15 16 17 18 19 20 21 22 23 24 25 26 27] 7 LastButtonID = 27 EndX = (1032 - 64) - 1 ScreenY = 720 StartX = 320 need_mos_enlarge = 0 // we already have 1280x135 MOS END ELSE PATCH_IF (Panel_Y >= 678) BEGIN // Y >= 768 TEXT_SPRINT MOSNAME "GMPWMSG0.MOS" PATCH_IF (TutuGUI = 1) BEGIN TEXT_SPRINT HMode "H400" END ELSE BEGIN TEXT_SPRINT HMode "H600" END END ELSE PATCH_IF (Panel_Y >= 500) BEGIN // Y >= 600 TEXT_SPRINT MOSNAME "GMPWMSG8.MOS" PATCH_IF (TutuGUI = 1) BEGIN TEXT_SPRINT HMode "H250" END ELSE BEGIN TEXT_SPRINT HMode "H390" END END ELSE // Y < 600 PATCH_IF (TutuGUI = 1) BEGIN TEXT_SPRINT MOSNAME "GMPWMSGB.MOS" // TutuGUI TEXT_SPRINT HMode "H150" END ELSE BEGIN TEXT_SPRINT MOSNAME "GUICONTB.MOS" TEXT_SPRINT HMode "H300" END SET NewBackgroundWidth = PanelWidth END END // Loot Buttons SET ii = 0 SET currPanelIdx = ContainerPanelNum FOR (ii = StartButtonID; ii <= LastButtonID; ii+= 1) BEGIN READ_SHORT (%offPanels% + %currPanelIdx% * 0x1c + 0xe) nPanelControls READ_SHORT (%offPanels% + %currPanelIdx% * 0x1c + 0x18) idxPanelControl //add control READ_LONG (%offControlTbl% + (%idxPanelControl% + %nPanelControls%) * 0x8) offControlThis INSERT_BYTES (%offControlThis%) 0x20 WRITE_SHORT (%offControlThis%) %ii% //controlIdx WRITE_SHORT (%offControlThis% + 0x2) 0 //bufferSize WRITE_SHORT (%offControlThis% + 0x4) (StartX + ScrollGap + (%ii% - StartButtonID) * 42) // X WRITE_SHORT (%offControlThis% + 0x6) StartY // Y WRITE_SHORT (%offControlThis% + 0x8) 42 //width WRITE_SHORT (%offControlThis% + 0xa) 42 //height WRITE_BYTE (%offControlThis% + 0xc) 0 //type = BUTTON WRITE_BYTE (%offControlThis% + 0xd) 0 //unknown WRITE_ASCII (%offControlThis% + 0xe) "STONSLOT" #8 WRITE_BYTE (%offControlThis% + 0x16) 0 //anim cycle WRITE_BYTE (%offControlThis% + 0x17) 0 //text flags WRITE_SHORT (%offControlThis% + 0x18) 0 //frame unpressed WRITE_SHORT (%offControlThis% + 0x1a) 1 //frame pressed WRITE_SHORT (%offControlThis% + 0x1c) 0 //frame selected WRITE_SHORT (%offControlThis% + 0x1e) 0 //frame disabled //updating all existing control table offsets FOR (i = %idxPanelControl% + %nPanelControls%; i < nControls; i += 1) BEGIN READ_SHORT (%offControlTbl% + %i% * 0x8) offControl SET offControl += 0x20 WRITE_SHORT (%offControlTbl% + %i% * 0x8) %offControl% END //add control table entry INSERT_BYTES (%offControlTbl% + (%idxPanelControl% + %nPanelControls%) * 0x8) 0x8 WRITE_LONG (%offControlTbl% + (%idxPanelControl% + %nPanelControls%) * 0x8) %offControlThis% //offset WRITE_LONG (%offControlTbl% + (%idxPanelControl% + %nPanelControls%) * 0x8 + 0x4) 0x20 //length SET nControls += 1 //update all control table offsets FOR (i = 0; i < nControls; i += 1) BEGIN READ_SHORT (%offControlTbl% + %i% * 0x8) offControl SET offControl += 0x8 WRITE_SHORT (%offControlTbl% + %i% * 0x8) %offControl% END //update control numbers SET nPanelControls += 1 WRITE_SHORT (%offPanels% + %currPanelIdx% * 0x1c + 0xe) %nPanelControls% //update panel control indices FOR (i = %currPanelIdx% + 1; i < nPanels; i += 1) BEGIN READ_SHORT (%offPanels% + %i% * 0x1c + 0x18) idxPanelControl SET idxPanelControl += 1 WRITE_SHORT (%offPanels% + %i% * 0x1c + 0x18) %idxPanelControl% END END // Left Scroll READ_SHORT (%offPanels% + %currPanelIdx% * 0x1c + 0xe) nPanelControls READ_SHORT (%offPanels% + %currPanelIdx% * 0x1c + 0x18) idxPanelControl //add control READ_LONG (%offControlTbl% + (%idxPanelControl% + %nPanelControls%) * 0x8) offControlThis INSERT_BYTES (%offControlThis%) 0x20 WRITE_SHORT (%offControlThis%) 6 //controlIdx WRITE_SHORT (%offControlThis% + 0x2) 0 //bufferSize WRITE_SHORT (%offControlThis% + 0x4) StartX // X WRITE_SHORT (%offControlThis% + 0x6) (StartY + 42/2 - (ScrollButtonHeight + 1)/2 ) // Y WRITE_SHORT (%offControlThis% + 0x8) ScrollButtonWidth //width WRITE_SHORT (%offControlThis% + 0xa) ScrollButtonHeight //height WRITE_BYTE (%offControlThis% + 0xc) 0 //type = BUTTON WRITE_BYTE (%offControlThis% + 0xd) 0 //unknown WRITE_ASCII (%offControlThis% + 0xe) "GUISLDR" #8 WRITE_BYTE (%offControlThis% + 0x16) 0 //anim cycle WRITE_BYTE (%offControlThis% + 0x17) 0 //text flags WRITE_SHORT (%offControlThis% + 0x18) 0 //frame unpressed WRITE_SHORT (%offControlThis% + 0x1a) 1 //frame pressed WRITE_SHORT (%offControlThis% + 0x1c) 0 //frame selected WRITE_SHORT (%offControlThis% + 0x1e) 2 //frame disabled //updating all existing control table offsets FOR (i = %idxPanelControl% + %nPanelControls%; i < nControls; i += 1) BEGIN READ_SHORT (%offControlTbl% + %i% * 0x8) offControl SET offControl += 0x20 WRITE_SHORT (%offControlTbl% + %i% * 0x8) %offControl% END //add control table entry INSERT_BYTES (%offControlTbl% + (%idxPanelControl% + %nPanelControls%) * 0x8) 0x8 WRITE_LONG (%offControlTbl% + (%idxPanelControl% + %nPanelControls%) * 0x8) %offControlThis% //offset WRITE_LONG (%offControlTbl% + (%idxPanelControl% + %nPanelControls%) * 0x8 + 0x4) 0x20 //length SET nControls += 1 //update all control table offsets FOR (i = 0; i < nControls; i += 1) BEGIN READ_SHORT (%offControlTbl% + %i% * 0x8) offControl SET offControl += 0x8 WRITE_SHORT (%offControlTbl% + %i% * 0x8) %offControl% END //update control numbers SET nPanelControls += 1 WRITE_SHORT (%offPanels% + %currPanelIdx% * 0x1c + 0xe) %nPanelControls% //update panel control indices FOR (i = %currPanelIdx% + 1; i < nPanels; i += 1) BEGIN READ_SHORT (%offPanels% + %i% * 0x1c + 0x18) idxPanelControl SET idxPanelControl += 1 WRITE_SHORT (%offPanels% + %i% * 0x1c + 0x18) %idxPanelControl% END // Right Scroll READ_SHORT (%offPanels% + %currPanelIdx% * 0x1c + 0xe) nPanelControls READ_SHORT (%offPanels% + %currPanelIdx% * 0x1c + 0x18) idxPanelControl //add control READ_LONG (%offControlTbl% + (%idxPanelControl% + %nPanelControls%) * 0x8) offControlThis INSERT_BYTES (%offControlThis%) 0x20 WRITE_SHORT (%offControlThis%) 7 //controlIdx WRITE_SHORT (%offControlThis% + 0x2) 0 //bufferSize WRITE_SHORT (%offControlThis% + 0x4) (EndX - ScrollButtonWidth) - 4 // X WRITE_SHORT (%offControlThis% + 0x6) (StartY + 42/2 - (ScrollButtonHeight + 1)/2) // Y WRITE_SHORT (%offControlThis% + 0x8) ScrollButtonWidth //width WRITE_SHORT (%offControlThis% + 0xa) ScrollButtonHeight //height WRITE_BYTE (%offControlThis% + 0xc) 0 //type = BUTTON WRITE_BYTE (%offControlThis% + 0xd) 0 //unknown WRITE_ASCII (%offControlThis% + 0xe) "GUISLDR" #8 WRITE_BYTE (%offControlThis% + 0x16) 0 //anim cycle WRITE_BYTE (%offControlThis% + 0x17) 0 //text flags WRITE_SHORT (%offControlThis% + 0x18) 0 //frame unpressed WRITE_SHORT (%offControlThis% + 0x1a) 1 //frame pressed WRITE_SHORT (%offControlThis% + 0x1c) 0 //frame selected WRITE_SHORT (%offControlThis% + 0x1e) 2 //frame disabled //updating all existing control table offsets FOR (i = %idxPanelControl% + %nPanelControls%; i < nControls; i += 1) BEGIN READ_SHORT (%offControlTbl% + %i% * 0x8) offControl SET offControl += 0x20 WRITE_SHORT (%offControlTbl% + %i% * 0x8) %offControl% END //add control table entry INSERT_BYTES (%offControlTbl% + (%idxPanelControl% + %nPanelControls%) * 0x8) 0x8 WRITE_LONG (%offControlTbl% + (%idxPanelControl% + %nPanelControls%) * 0x8) %offControlThis% //offset WRITE_LONG (%offControlTbl% + (%idxPanelControl% + %nPanelControls%) * 0x8 + 0x4) 0x20 //length SET nControls += 1 //update all control table offsets FOR (i = 0; i < nControls; i += 1) BEGIN READ_SHORT (%offControlTbl% + %i% * 0x8) offControl SET offControl += 0x8 WRITE_SHORT (%offControlTbl% + %i% * 0x8) %offControl% END //update control numbers SET nPanelControls += 1 WRITE_SHORT (%offPanels% + %currPanelIdx% * 0x1c + 0xe) %nPanelControls% //update panel control indices FOR (i = %currPanelIdx% + 1; i < nPanels; i += 1) BEGIN READ_SHORT (%offPanels% + %i% * 0x1c + 0x18) idxPanelControl SET idxPanelControl += 1 WRITE_SHORT (%offPanels% + %i% * 0x1c + 0x18) %idxPanelControl% END BUT_ONLY ACTION_IF (%option% = 0) BEGIN COPY "TobEx_ini/TobExTweak.ini" "TobEx_ini/TobExTweak.ini" APPEND_FILE "bg2improvedgui/loot_panel/files/TobEx_nogroups.txt" BUT_ONLY END ACTION_IF (%option% = 1) BEGIN // Group Mode COPY "TobEx_ini/TobExTweak.ini" "TobEx_ini/TobExTweak.ini" APPEND_FILE "bg2improvedgui/loot_panel/files/TobEx_groups.txt" BUT_ONLY END ACTION_IF (%need_mos_enlarge% = 1) BEGIN // enlarge MOS width COPY_EXISTING ~%MOSNAME%~ ~override~ EXTEND_MOS ~%HMode%~ %NewBackgroundWidth% PATCH_PRINT ~%MOSNAME% enlarged to %NewBackgroundWidth%, %HMode%~ BUT_ONLY END END // ACTION_FUNCTION