Add mobile touch UI and AVA2 biology system with server tools

This commit is contained in:
shen
2026-10-14 19:12:38 -07:00
parent e7f2202a94
commit 6472d17306
68 changed files with 4447 additions and 197 deletions
+81
View File
@@ -161,6 +161,7 @@ struct GameSingletons
std::unique_ptr<GameSingletons> g_game_singletons;
bool g_host_hardware_cursor_enabled = false;
bool g_touch_input = false;
int g_inventory_touch_target = 0;
bool fail(std::string* error, const std::string& text)
{
@@ -526,6 +527,76 @@ bool quick_slot_image_uv(CGraphicImage* image, std::string* texture, float uv[4]
}
}
// PORT: presentation only; skill validation remains in RequestUseLocalQuickSlot.
QuickSlotState LocalQuickSlotState(int localSlotIndex)
{
QuickSlotState state;
if (!g_game_singletons || localSlotIndex < 0 || localSlotIndex >= 8) return state;
DWORD type = SLOT_TYPE_NONE, position = 0;
auto& player = CPythonPlayer::Instance();
player.GetLocalQuickSlotData(static_cast<DWORD>(localSlotIndex), &type, &position);
if (type == SLOT_TYPE_SKILL) {
state.learned = player.GetSkillLevel(position) > 0;
state.active = player.IsSkillActive(position);
if (player.IsSkillCoolTime(position))
state.remaining = std::max(0.0f, player.GetSkillCoolTime(position) - player.GetSkillElapsedCoolTime(position));
}
return state;
}
void SetInventoryTouchTarget(float logicalSize)
{
if (!g_touch_input || !g_launcher) return;
const int size = std::max(48, int(std::ceil(logicalSize)));
if (size == g_inventory_touch_target) return;
std::string error;
if (RunLine(("__import__('mt_mobile_inventory').touch_target = " + std::to_string(size)).c_str(), &error))
g_inventory_touch_target = size;
}
void SetInventoryTap(bool tap)
{
if (!g_touch_input) return;
std::string error;
RunLine(tap ? "__import__('mt_mobile_inventory').tap = True" :
"__import__('mt_mobile_inventory').tap = False", &error);
}
void SetInventoryDoubleTap(bool tap)
{
if (!g_touch_input) return;
std::string error;
RunLine(tap ? "__import__('mt_mobile_inventory').double_tap = True" :
"__import__('mt_mobile_inventory').double_tap = False", &error);
}
void SetInventoryDrag(bool dragging)
{
if (!g_touch_input) return;
std::string error;
RunLine(dragging ? "__import__('mt_mobile_inventory').SetDrag(True)" :
"__import__('mt_mobile_inventory').SetDrag(False)", &error);
}
bool FinishInventoryDrag(int x, int y)
{
if (!g_touch_input || !g_window_manager) return false;
UIMouseMove(x, y);
bool shop_target = false;
for (auto* picked = g_window_manager->GetPointWindow(); picked; picked = picked->GetParent())
if (std::string(picked->GetName()) == "ShopDialog") {
shop_target = true;
break;
}
std::string result, error;
if (!Evaluate(shop_target ? "__import__('mt_mobile_inventory').Drop(True)" :
"__import__('mt_mobile_inventory').Drop(False)", &result, &error)) {
UIDeattachObject();
return true; // Never fall back to a direct shop sale after a failed confirmation handler.
}
return result == "True" || result == "1";
}
bool LocalQuickSlotIcon(int localSlotIndex, std::string* texture, float uv[4], int* count)
{
if (!g_game_singletons || localSlotIndex < 0 || localSlotIndex >= 8) return false;
@@ -915,8 +986,11 @@ namespace PythonBoot
#include "FrameRateOptionScript.inc"
#include "UIScaleOptionScript.inc"
#include "InventoryPagesScript.inc"
#include "MobileInventoryScript.inc"
#include "MallHintScript.inc"
#include "ServerBonusScript.inc"
#include "MobileHUDScript.inc"
#include "BiologScript.inc"
static void install_script_module(const char* c_szModule, const char* c_szScript)
{
@@ -975,8 +1049,15 @@ bool RunMainScript(const char* lpCmdLine, std::string* error)
install_script_module("mt_framerate", c_szFrameRateOptionScript);
install_script_module("mt_uiscale", c_szUIScaleOptionScript);
install_script_module("mt_inventory", c_szInventoryPagesScript);
if (g_touch_input) {
g_inventory_touch_target = 0;
install_script_module("mt_mobile_inventory", c_szMobileInventoryScript);
}
install_script_module("mt_mallhint", c_szMallHintScript);
install_script_module("mt_bonuses", c_szServerBonusScript);
install_script_module("mt_biolog", c_szBiologScript);
if (g_touch_input)
install_script_module("mt_mobile_hud", c_szMobileHUDScript);
}
return true;
}