- gr2: BitKnit2 decompression, 64-bit LE files, compressed curves - net: remaining GamePhase handlers, generated GC packet table - python: event/chat/chr/minimap/guild/quest/messenger/shop-search and other native modules ported against the AVA2 Windows client - render: D3D8 fixed-function lighting in Gr2ModelRenderer, terrain without baked shade; cape/NPC equipment attachment - tests + audits updated; docs/PORT-PLAN.md and WINDOWS-PARITY.md Batch 4 (render pipeline: background.*, app.RenderGame/UpdateGame, camera bindings, main.cpp fake-content removal) is still in progress. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
179 lines
7.0 KiB
C++
179 lines
7.0 KiB
C++
#include "python_runtime.h"
|
|
#include "python_net.h"
|
|
#include "eter_ui/PythonWindowManager.h"
|
|
#include "eter_image/GrpDevice.h"
|
|
#include <SDL3/SDL.h>
|
|
#include <iostream>
|
|
#include <cassert>
|
|
#include "test_rundir.h"
|
|
|
|
int main(int argc, char** argv) {
|
|
if (argc != 3) return 2;
|
|
if (!ava2_test::EnterTestRunDir()) return ava2_test::kSkip;
|
|
try {
|
|
ava2::PythonRuntime runtime(argv[1], argv[2]);
|
|
auto* wm = runtime.window_manager();
|
|
assert(wm != nullptr);
|
|
|
|
// Screen size & aspect verification
|
|
wm->SetScreenSize(1024, 768);
|
|
wm->SetResolution(1024, 768);
|
|
assert(wm->GetScreenWidth() == 1024);
|
|
assert(wm->GetScreenHeight() == 768);
|
|
assert(std::abs(wm->GetAspect() - (1024.0f / 768.0f)) < 0.001f);
|
|
|
|
// Python integration verification
|
|
runtime.execute(
|
|
"import wndMgr, ui\n"
|
|
"w = ui.Window()\n"
|
|
"w.SetSize(200, 100)\n"
|
|
"w.SetPosition(50, 60)\n"
|
|
"w.Show()\n"
|
|
"assert w.IsShow() == 1\n"
|
|
"assert w.GetWidth() == 200\n"
|
|
"assert w.GetHeight() == 100\n"
|
|
"assert w.GetLocalPosition() == (50, 60)\n"
|
|
"\n"
|
|
"btn = ui.Button()\n"
|
|
"btn.SetParent(w)\n"
|
|
"btn.SetPosition(10, 20)\n"
|
|
"btn.SetSize(80, 30)\n"
|
|
"btn.Show()\n"
|
|
"assert btn.IsShow() == 1\n"
|
|
"assert btn.GetLocalPosition() == (10, 20)\n"
|
|
"assert btn.GetGlobalPosition() == (60, 80)\n"
|
|
"\n"
|
|
"img = ui.ExpandedImageBox()\n"
|
|
"img.SetParent(w)\n"
|
|
"img.SetPosition(0, 0)\n"
|
|
"img.LoadImage('locale/en/ui/loading/loading0.sub')\n"
|
|
"img.Show()\n"
|
|
"assert img.IsShow() == 1\n"
|
|
"assert img.GetWidth() == 1920\n"
|
|
"assert img.GetHeight() == 1080\n"
|
|
"\n"
|
|
"txt = ui.TextLine()\n"
|
|
"txt.SetParent(w)\n"
|
|
"txt.SetText('AVA2 Cross Platform')\n"
|
|
"assert txt.GetText() == 'AVA2 Cross Platform'\n"
|
|
"\n"
|
|
"import networkModule\n"
|
|
"stream = networkModule.MainStream()\n"
|
|
"stream.Create()\n"
|
|
"stream.SetLoginPhase()\n"
|
|
"print 'Original AVA2 Login Phase with real LoginWindow loaded successfully!'\n"
|
|
"lw = stream.curPhaseWindow\n"
|
|
"assert lw != 0\n"
|
|
"lw.idEditLine.SetText('player1')\n"
|
|
"lw.pwdEditLine.SetText('password123')\n"
|
|
"assert lw.idEditLine.GetText() == 'player1'\n"
|
|
"assert lw.pwdEditLine.GetText() == 'password123'\n"
|
|
"stream.SetConnectInfo('127.0.0.1', 13000, '127.0.0.1', 11002)\n"
|
|
"lw.loginButton.CallEvent()\n"
|
|
"print 'Login button event executed successfully and triggered network stream connect!'\n"
|
|
);
|
|
|
|
// Setup mock character data for character selection
|
|
ava2::Character c0;
|
|
c0.id = 1001;
|
|
c0.name = "WarriorHero";
|
|
c0.job = 0; // RACE_WARRIOR_M
|
|
c0.level = 75;
|
|
c0.strength = 90;
|
|
c0.dexterity = 40;
|
|
c0.health = 90;
|
|
c0.intelligence = 20;
|
|
c0.main_part = 11299; // Black Steel Armor
|
|
c0.play_minutes = 3600;
|
|
ava2::set_mock_character(0, c0);
|
|
ava2::set_mock_empire(1); // Empire A (Shinsoo)
|
|
|
|
runtime.execute(
|
|
"stream.SetSelectCharacterPhase()\n"
|
|
"print 'Original AVA2 Select Character Phase loaded successfully!'\n"
|
|
"sw = stream.curPhaseWindow\n"
|
|
"assert sw != 0\n"
|
|
"assert sw.GetCharacterSlotID(0) == 1001\n"
|
|
"assert sw.CharacterSlot_0_Name.GetText() == 'WarriorHero'\n"
|
|
"print 'SelectCharacterWindow successfully rendered slot 0 with name: ' + sw.CharacterSlot_0_Name.GetText()\n"
|
|
"\n"
|
|
"# Transition to Create Character Phase\n"
|
|
"import net\n"
|
|
"stream.SetCharacterSlot(1)\n"
|
|
"stream.SetCreateCharacterPhase()\n"
|
|
"print 'Original AVA2 Create Character Phase loaded successfully!'\n"
|
|
"cw = stream.curPhaseWindow\n"
|
|
"assert cw != 0\n"
|
|
"# Select Sura class (slot 2)\n"
|
|
"cw.CharacterSlot_2.CallEvent()\n"
|
|
"# Select Male gender (button 0)\n"
|
|
"cw.genderButtonList[0].CallEvent()\n"
|
|
"# Select Shape 1\n"
|
|
"cw.shapeButtonList[1].CallEvent()\n"
|
|
"# Set Character Name\n"
|
|
"cw.editCharacterName.SetText('SuraMage')\n"
|
|
"assert cw.editCharacterName.GetText() == 'SuraMage'\n"
|
|
"# Trigger creation\n"
|
|
"cw.btnCreate.CallEvent()\n"
|
|
"# Dispatch creation packet and trigger successful creation transition\n"
|
|
"net.SendCreateCharacterPacket(1, 'SuraMage', cw.reservingRaceIndex, cw.reservingShapeIndex, 3, 5, 5, 3)\n"
|
|
"sw2 = stream.curPhaseWindow\n"
|
|
"assert sw2 != 0\n"
|
|
"assert sw2.CharacterSlot_1_Name.GetText() == 'SuraMage'\n"
|
|
"print 'Character creation successfully created SuraMage in slot 1 and returned to SelectCharacterWindow!'\n"
|
|
"\n"
|
|
"# Transition to Loading Phase\n"
|
|
"stream.SetLoadingPhase()\n"
|
|
"print 'Original AVA2 Loading Phase loaded successfully!'\n"
|
|
"load_wnd = stream.curPhaseWindow\n"
|
|
"assert load_wnd != 0\n"
|
|
"\n"
|
|
"import app\n"
|
|
"stream.SetGamePhase()\n"
|
|
"gw = stream.curPhaseWindow\n"
|
|
"assert gw != 0\n"
|
|
"gw.Open()\n"
|
|
"gw.OnUpdate()\n"
|
|
"gw.OnRender()\n"
|
|
"gw.OnKeyDown(app.DIK_W)\n"
|
|
"gw.OnKeyUp(app.DIK_W)\n"
|
|
"gw.OnKeyDown(app.DIK_I)\n"
|
|
"print 'Original AVA2 Game Phase loaded and updated successfully!'\n"
|
|
);
|
|
|
|
SDL_Surface* surface = SDL_CreateSurface(1024, 768, SDL_PIXELFORMAT_RGBA32);
|
|
assert(surface != nullptr);
|
|
SDL_Renderer* renderer = SDL_CreateSoftwareRenderer(surface);
|
|
assert(renderer != nullptr);
|
|
CGraphicDevice device;
|
|
device.Init(renderer);
|
|
device.BeginScene();
|
|
|
|
wm->Update();
|
|
wm->Render();
|
|
|
|
device.EndScene();
|
|
|
|
// Verify offscreen surface has rendered UI content
|
|
uint32_t* pixels = reinterpret_cast<uint32_t*>(surface->pixels);
|
|
bool hasNonZeroPixel = false;
|
|
for (int i = 0; i < 1024 * 768; ++i) {
|
|
if (pixels[i] != 0) {
|
|
hasNonZeroPixel = true;
|
|
break;
|
|
}
|
|
}
|
|
assert(hasNonZeroPixel && "UI and real texture rendering produced visible pixels");
|
|
|
|
device.Init(nullptr);
|
|
SDL_DestroyRenderer(renderer);
|
|
SDL_DestroySurface(surface);
|
|
|
|
fprintf(stderr, "=== TEST REACHED END SUCCESSFULLY ===\n"); std::cout << "AVA2 Window Manager & Window tree & Real image loading & SDL3 2D rendering passed successfully!" << std::endl;
|
|
return 0;
|
|
} catch (const std::exception& e) {
|
|
std::cerr << "Exception: " << e.what() << "\n";
|
|
return 1;
|
|
}
|
|
}
|