cleanup: remove Godot-era test data, formats/, dead proto reader and duplicates

- test/: bgfx/Godot render goldens and compare shots nothing reads any more;
  the Granny oracle result m2-numeric.json moves to oracle/
- formats/: only the .spt sniffer was still linked; it moves into
  platform/SpeedTreeLib, the rest and tools/map_probe go
- bgm/ duplicated Client/BGM byte for byte; tools/root archived root scripts
  that root.epk already holds; extension/src/proto had no build reference
- GEMINI.md duplicated AGENTS.md

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shenlei
2026-09-29 18:43:19 +09:00
co-authored by Claude Opus 5.5
parent 0137f852d3
commit 70710477cf
198 changed files with 8 additions and 69264 deletions
-3
View File
@@ -13,9 +13,6 @@ target_link_libraries(oracle_diff PRIVATE xrender::libgr2)
add_executable(anim_probe anim_probe/main.cpp)
target_link_libraries(anim_probe PRIVATE xrender::libgr2)
# SHINSOO W0:一张地图的 load report(setting / textureset / 区块二进制 / areadata)
add_executable(map_probe map_probe/main.cpp)
target_link_libraries(map_probe PRIVATE xrender::formats)
# gr2dump --gltf 需要 tinygltf(M0 T8 辅助、可延后):
# if(TARGET tinygltf) target_link_libraries(gr2dump PRIVATE tinygltf) endif()
-202
View File
@@ -1,202 +0,0 @@
// map_probe — SHINSOO-WORLD-RENDERING.md W0 的 load report。
//
// map_probe <assets_root> [map_rel] map_rel 默认 OutdoorA1/metin2_map_a1
//
// 扫一张地图:setting.txt / TextureSet / 每个区块的 6 类文件 / areadata,
// 逐项打印「成功 / 失败 + 原因」,末尾给汇总。不加载 .msenv / Property(W0 剩余项)。
#include "area_data.h"
#include "asset_resolver.h"
#include "environment.h"
#include "m2_coord.h"
#include "map_setting.h"
#include "property.h"
#include "splat.h"
#include "terrain_files.h"
#include "texture_set.h"
#include <cstdio>
#include <cstdlib>
#include <map>
#include <set>
#include <string>
using namespace fmt;
static int g_ok = 0, g_bad = 0;
static void line(const char* tag, bool ok, const std::string& detail) {
std::printf(" [%s] %-28s %s\n", ok ? "OK " : "ERR", tag, detail.c_str());
ok ? ++g_ok : ++g_bad;
}
int main(int argc, char** argv) {
if (argc < 2) {
std::fprintf(stderr, "usage: map_probe <assets_root> [map_rel]\n");
return 2;
}
std::string assets = argv[1];
std::string map_rel = argc > 2 ? argv[2] : "OutdoorA1/metin2_map_a1";
std::string map = assets + "/" + map_rel;
std::printf("== map_probe: %s ==\n", map.c_str());
std::string err;
MapSetting s;
if (!parse_map_setting_file(map + "/setting.txt", s, &err)) {
line("setting.txt", false, err);
return 1;
}
line("setting.txt", true,
"MapSize " + std::to_string(s.map_size_x) + "x" + std::to_string(s.map_size_y) +
" CellScale " + std::to_string(s.cell_scale) + " HeightScale " +
std::to_string(s.height_scale) + " env=" + s.environment);
// TextureSet:setting 里是 `textureset\metin2_A1.txt`,实盘在 assets/textureset/textureset/ 且小写
{
std::string rel = s.texture_set;
for (auto& c : rel)
if (c == '\\') c = '/';
for (auto& c : rel) c = (char)std::tolower((unsigned char)c);
std::string p = assets + "/textureset/" + rel;
TextureSet ts;
if (parse_texture_set_file(p, ts, &err))
line("TextureSet", true,
std::to_string(ts.layers.size()) + " layers (+1 empty = runtime " +
std::to_string(ts.runtime_count()) + ")");
else
line("TextureSet", false, p + " : " + err);
}
// 每个区块
int chunks_found = 0, hm_ok = 0, tile_ok = 0, attr_ok = 0, water_ok = 0, area_ok = 0;
long total_objs = 0;
std::map<uint32_t, int> crc_hist;
for (int tx = 0; tx < s.map_size_x; ++tx) {
for (int ty = 0; ty < s.map_size_y; ++ty) {
std::string dir = map + "/" + m2coord::tile_dir(tx, ty);
std::string e;
HeightMap hm;
TileMap tm;
AttrMap am;
WaterMap wm;
AreaData ad;
bool any = false;
if (load_height_map(dir + "/height.raw", hm, &e)) { ++hm_ok; any = true; }
if (load_tile_map(dir + "/tile.raw", tm, &e)) ++tile_ok;
if (load_attr_map(dir + "/attr.atr", am, &e)) ++attr_ok;
if (load_water_map(dir + "/water.wtr", wm, &e)) ++water_ok;
if (parse_area_data_file(dir + "/areadata.txt", ad, &e)) {
++area_ok;
total_objs += (long)ad.objects.size();
for (auto& o : ad.objects) crc_hist[o.crc]++;
}
if (any) ++chunks_found;
}
}
int n = s.chunk_count();
line("chunk dirs", chunks_found == n,
std::to_string(chunks_found) + "/" + std::to_string(n));
line("height.raw", hm_ok == n, std::to_string(hm_ok) + "/" + std::to_string(n) + " as 131x131");
line("tile.raw", tile_ok == n, std::to_string(tile_ok) + "/" + std::to_string(n) + " as 258x258");
line("attr.atr", attr_ok == n, std::to_string(attr_ok) + "/" + std::to_string(n) + " magic 2634");
line("water.wtr", water_ok == n, std::to_string(water_ok) + "/" + std::to_string(n) + " magic 5426");
line("areadata.txt", area_ok == n, std::to_string(area_ok) + "/" + std::to_string(n) + " parsed");
std::printf(" ---- AreaData: %ld objects, %zu distinct Property CRCs ----\n",
total_objs, crc_hist.size());
// splat(区块 000000)
{
TileMap tm;
std::string e;
if (load_tile_map(map + "/000000/tile.raw", tm, &e)) {
SplatSet ss;
build_splat(tm, 18, ss);
std::string used;
for (auto& L : ss.layers)
used += std::to_string(L.layer) + "(" + std::to_string(L.coverage) + ") ";
line("splat 000000", !ss.layers.empty(),
std::to_string(ss.layers.size()) + " used layers: " + used);
}
}
// .msenv(虚拟路径 environment\<name> -> ETC/ymir work/environment/<name>)
Environment env;
{
std::string p = assets + "/ETC/ymir work/environment/" + s.environment;
for (auto& c : p) c = (c == '\\') ? '/' : (char)std::tolower((unsigned char)c);
// 只小写文件名部分即可,这里整体小写对 macOS/实盘均成立
std::string p2 = assets + "/ETC/ymir work/environment/" + s.environment;
std::string lp = p2;
for (auto& c : lp) c = (char)std::tolower((unsigned char)c);
if (parse_environment_file(lp, env, &err))
line(".msenv", true,
s.environment + " : fog=" + (env.fog.enable ? "on" : "off") + " gradient=" +
std::to_string(env.sky.gradient.size()) + " rows, cloudtex=" +
env.sky.cloud_texture);
else
line(".msenv", false, lp + " : " + err);
}
// Property CRC 注册表
PropertyRegistry reg;
if (reg.scan(assets + "/Property", &err)) {
std::string bytype;
for (auto& [k, v] : reg.type_counts) bytype += k + "=" + std::to_string(v) + " ";
line("Property registry", reg.parse_failed == 0,
std::to_string(reg.by_crc.size()) + " CRCs (" + std::to_string(reg.files_scanned) +
" files, " + std::to_string(reg.parse_failed) + " failed, " +
std::to_string(reg.crc_collisions) + " collisions) [" + bytype + "]");
// areadata 的 CRC 覆盖率
long hit = 0, total = 0;
std::set<uint32_t> missing;
for (auto& [crc, cnt] : crc_hist) {
total++;
if (reg.find(crc)) hit++;
else missing.insert(crc);
}
line("AreaData CRC coverage", missing.empty(),
std::to_string(hit) + "/" + std::to_string(total) + " distinct CRCs resolve" +
(missing.empty() ? "" : " (missing e.g. " + std::to_string(*missing.begin()) + ")"));
} else {
line("Property registry", false, err);
}
// AssetResolver
AssetResolver res;
if (res.build(assets, AssetResolver::default_priority(), &err)) {
line("AssetResolver", true,
std::to_string(res.files_indexed) + " files, " +
std::to_string(res.by_ymir.size()) + " ymir keys, " +
std::to_string(res.ymir_conflicts) + " conflicts");
// TextureSet 图层贴图解析率
TextureSet ts2;
std::string rel = s.texture_set, e3;
for (auto& c : rel) c = (c == '\\') ? '/' : (char)std::tolower((unsigned char)c);
if (parse_texture_set_file(assets + "/textureset/" + rel, ts2, &e3)) {
int miss = 0;
for (auto& L : ts2.layers)
if (res.resolve(L.texture, nullptr).empty()) ++miss;
line("TextureSet -> assets", miss == 0,
std::to_string(ts2.layers.size() - miss) + "/" +
std::to_string(ts2.layers.size()) + " layer textures resolve");
}
// Property 引用的模型文件解析率(buildingfile / treefile / effectfile)
int pref = 0, pmiss = 0;
for (auto& [crc, p] : reg.by_crc) {
for (const char* k : {"buildingfile", "treefile", "effectfile", "modelfile"}) {
std::string v = p.get(k);
if (v.empty()) continue;
++pref;
if (res.resolve(v, nullptr).empty()) ++pmiss;
}
}
line("Property models -> assets", true,
std::to_string(pref - pmiss) + "/" + std::to_string(pref) +
" resolve (misses incl. .spt trees / missing packs)");
} else {
line("AssetResolver", false, err);
}
std::printf("\n== summary: %d ok, %d err ==\n", g_ok, g_bad);
return g_bad ? 1 : 0;
}
-110
View File
@@ -1,110 +0,0 @@
map_a2 256000 665600 6 6
map_b2 102400 51200 6 6
map_c2 665600 281600 6 6
map_n_snowm_01 358400 153600 6 6
metin2_map_a1 409600 896000 4 5
metin2_map_a3 307200 819200 4 4
metin2_map_b1 0 102400 4 5
metin2_map_b3 102400 204800 4 4
metin2_map_c1 921600 204800 4 5
metin2_map_c3 819200 204800 4 4
metin2_map_deviltower1 204800 665600 3 3
metin2_map_milgyo 537600 51200 4 4
metin2_map_n_desert_01 204800 486400 6 6
metin2_map_n_flame_01 588800 614400 6 6
metin2_map_spiderdungeon 51200 486400 3 3
metin2_map_spiderdungeon_02 665600 435200 4 4
metin2_map_t1 0 25600 3 3
metin2_map_t2 6400 0 1 1
metin2_map_t3 32000 0 1 1
metin2_map_t4 57600 0 1 1
metin2_map_t5 793600 0 1 1
metin2_map_monkeydungeon 819200 51200 3 3
metin2_map_monkeydungeon 768000 435200 3 3
metin2_map_monkeydungeon 844800 435200 3 3
metin2_map_monkeydungeon 921600 435200 3 3
metin2_map_monkeydungeon_02 128000 640000 3 3
metin2_map_monkeydungeon_03 128000 716800 3 3
metin2_map_wedding_01 819200 0 1 1
metin2_map_guild_01 128000 0 2 2
metin2_map_guild_02 179200 0 2 2
metin2_map_guild_03 230400 0 2 2
metin2_map_trent 281600 0 2 2
metin2_map_trent02 1049600 0 4 4
gm_guild_build 83200 0 1 1
metin2_map_duel 844800 0 1 1
season1/metin2_map_WL_01 1049600 716800 6 6
season1/metin2_map_nusluck01 819200 716800 4 4
season1/metin2_map_oxevent 870400 0 2 2
season1/metin2_map_sungzi 921600 0 2 2
metin2_map_bf 972800 0 2 2
metin2_map_bf_02 921600 51200 2 2
metin2_map_bf_03 972800 51200 2 2
metin2_map_sungzi_flame_pass01 1024000 102400 4 4
metin2_map_sungzi_flame_pass02 1024000 204800 4 4
metin2_map_sungzi_flame_pass03 1024000 307200 4 4
season1/metin2_map_sungzi_flame_hill_01 1126400 102400 2 4
season1/metin2_map_sungzi_flame_hill_02 1126400 204800 2 4
season1/metin2_map_sungzi_flame_hill_03 1126400 307200 2 4
season1/metin2_map_sungzi_snow 1152000 0 3 3
season1/metin2_map_sungzi_snow_pass01 1177600 102400 2 4
season1/metin2_map_sungzi_snow_pass02 1177600 204800 2 4
season1/metin2_map_sungzi_snow_pass03 1177600 307200 2 4
season1/metin2_map_sungzi_desert_01 1228800 0 4 4
season1/metin2_map_sungzi_desert_hill_01 1228800 102400 2 4
season1/metin2_map_sungzi_desert_hill_02 1228800 204800 2 4
season1/metin2_map_sungzi_desert_hill_03 1228800 307200 2 4
season1/metin2_map_sungzi_milgyo 1331200 0 3 3
season1/metin2_map_sungzi 1408000 0 3 3
season1/metin2_map_sungzi_snow 1484800 0 3 3
season1/metin2_map_sungzi_desert_01 1561600 0 3 3
season1/metin2_map_sungzi_milgyo_pass01 1280000 102400 2 4
season1/metin2_map_sungzi_milgyo_pass02 1280000 204800 2 4
season1/metin2_map_sungzi_milgyo_pass03 1280000 307200 2 4
season1/metin2_map_sungzi_flame_hill_01 1331200 102400 2 4
season1/metin2_map_sungzi_flame_hill_02 1331200 204800 2 4
season1/metin2_map_sungzi_flame_hill_03 1331200 307200 2 4
season1/metin2_map_sungzi_snow_pass01 1382400 102400 2 4
season1/metin2_map_sungzi_snow_pass02 1382400 204800 2 4
season1/metin2_map_sungzi_snow_pass03 1382400 307200 2 4
season1/metin2_map_sungzi_desert_hill_01 1433600 102400 2 4
season1/metin2_map_sungzi_desert_hill_02 1433600 204800 2 4
season1/metin2_map_sungzi_desert_hill_03 1433600 307200 2 4
season1/metin2_map_ew02 256000 51200 4 4
season2/metin2_map_empirewar01 972800 102400 2 2
season2/metin2_map_empirewar02 921600 153600 2 2
season2/metin2_map_empirewar03 972800 153600 2 2
season2/map_n_snowm_02 0 1049600 6 6
season2/metin2_map_milgyo_a 153600 1049600 4 4
season2/metin2_map_n_desert_02 307200 1049600 6 6
season2/metin2_map_n_flame_02 460800 1049600 6 6
season2/metin2_map_a2_1 614400 1049600 6 6
season2/metin2_map_trent_a 768000 1049600 2 2
season2/metin2_map_trent02_a 921600 1049600 3 3
season2/metin2_map_skipia_dungeon_01 0 1203200 6 6
metin2_map_skipia_dungeon_02 153600 1203200 6 6
season2/metin2_map_skipia_dungeon_01 0 1356800 6 6
season2/metin2_map_skipia_dungeon_01 0 1510400 6 6
season2/metin2_map_skipia_dungeon_01 0 1664000 6 6
metin2_map_skipia_dungeon_02 153600 1356800 6 6
metin2_map_skipia_dungeon_02 153600 1510400 6 6
metin2_map_skipia_dungeon_02 153600 1664000 6 6
season2/metin2_map_empirewar01 665600 230400 2 2
season2/metin2_map_empirewar02 716800 230400 2 2
season2/metin2_map_empirewar03 768000 230400 2 2
season1/metin2_map_oxevent 742400 0 2 2
metin2_map_skipia_dungeon_boss 819200 1049600 2 2
metin2_map_skipia_dungeon_boss 819200 1100800 2 2
metin2_map_skipia_dungeon_boss2 819200 1152000 2 2
metin2_map_skipia_dungeon_boss 819200 1203200 2 2
metin2_map_devilsCatacomb 307200 1203200 8 8
metin2_map_spiderdungeon_03 51200 563200 3 3
Metin2_map_CapeDragonHead 1024000 1664000 6 6
metin2_map_Mt_Thunder 1126400 1510400 4 6
metin2_map_dawnmistwood 1177600 1664000 7 4
metin2_map_BayBlackSand 1049600 1510400 3 6
metin2_guild_village_01 204800 204800 2 2
metin2_guild_village_02 614400 384000 2 2
metin2_guild_village_03 256000 819200 2 2
metin2_map_n_flame_dungeon_01 742400 614400 3 3
metin2_map_n_snow_dungeon_01 512000 153600 4 3
-37
View File
@@ -1,37 +0,0 @@
CHAT_RGB_TALK = (255, 255, 255)
CHAT_RGB_INFO = (255, 200, 200)
CHAT_RGB_NOTICE = (255, 230, 186)
CHAT_RGB_PARTY = (0, 255, 228)
CHAT_RGB_GUILD = (253, 255, 124)
#CHAT_RGB_GUILD = (231, 215, 255)
CHAT_RGB_COMMAND = (167, 255, 212)
CHAT_RGB_SHOUT = (167, 255, 212)
CHAT_RGB_WHISPER = (74, 225, 74)
CHR_NAME_RGB_MOB = (235, 22, 9)
CHR_NAME_RGB_NPC = (122, 231, 93)
CHR_NAME_RGB_PC = (255, 215, 76)
CHR_NAME_RGB_PK = (180, 100, 0)
CHR_NAME_RGB_PVP = (238, 54, 223)
CHR_NAME_RGB_PARTY = (128, 192, 255)
CHR_NAME_RGB_WARP = (136, 218, 241)
CHR_NAME_RGB_WAYPOINT = (255, 255, 255)
CHR_NAME_RGB_EMPIRE_MOB = (235, 22, 9)
CHR_NAME_RGB_EMPIRE_NPC = (122, 231, 93)
CHR_NAME_RGB_EMPIRE_PC_A = (157, 0, 0)
CHR_NAME_RGB_EMPIRE_PC_B = (222, 160, 47)
CHR_NAME_RGB_EMPIRE_PC_C = (23, 30, 138)
TITLE_RGB_GOOD_4 = ( 0, 204, 255)
TITLE_RGB_GOOD_3 = ( 0, 144, 255)
TITLE_RGB_GOOD_2 = ( 92, 110, 255)
TITLE_RGB_GOOD_1 = (155, 155, 255)
TITLE_RGB_NORMAL = (255, 255, 255)
TITLE_RGB_EVIL_1 = (207, 117, 0)
TITLE_RGB_EVIL_2 = (235, 83, 0)
TITLE_RGB_EVIL_3 = (227, 0, 0)
TITLE_RGB_EVIL_4 = (255, 0, 0)
-905
View File
@@ -1,905 +0,0 @@
import app
import grp
import wndMgr
import ui
import os
import sys
import stat
import chrmgr
import chr
import net
import background
import snd
import net
import player
import localeInfo
import uiScriptLocale
class Console(object):
def __init__(self, output):
self.dirNameList = []
self.fileNameList = []
self.output = output
self.curPathName = "D:\\Ymir Work\\"
self.collision = 0
self.bgPartDict = {
"terrain":background.PART_TERRAIN,
"object":background.PART_OBJECT,
"cloud":background.PART_CLOUD,
"tree":background.PART_TREE,
"water":background.PART_WATER,
"sky":background.PART_SKY,
}
self.bgSortDict = {
"distance":background.DISTANCE_SORT,
"texture":background.TEXTURE_SORT,
}
self.game = 0
def Close(self):
self.output = 0
def BindGameClass(self, game):
self.game = game
def Exit(self):
"Exit Program"
app.Exit()
def EnablePerformanceTime(self, mode, isEnable):
app.EnablePerformanceTime(mode, int(isEnable))
def ReloadLocale(self):
"Reload Locale"
import app
if app.ReloadLocale():
self.Print("RELOAD LOCALE OK")
else:
self.Print("RELOAD LOCALE FAILED")
def ReloadDevel(self):
"ReloadDevel"
import consoleModule
import uiGuild
import uiInventory
reload(uiGuild)
self.Print("ReloadGuild")
reload(uiInventory)
self.Print("ReloadInventory")
def ShowPerformanceInfo(self):
"Shows Performance Info"
self.Print(app.GetInfo(app.INFO_ACTOR))
self.Print(app.GetInfo(app.INFO_ITEM))
self.Print(app.GetInfo(app.INFO_EFFECT))
self.Print(app.GetInfo(app.INFO_TEXTTAIL))
def Disconnect(self):
"Disconnect by sending unknown packet"
net.SendStrangePacket()
def ToggleActorDirectionLine(self):
"Shows character's direction line"
chrmgr.ToggleDirectionLine()
def RegisterCharacterEffect(self, effectType, effectFileName):
"Set character's effect state (state number, bone name, effect filename/number)"
if effectFileName.isdigit():
effectFileName = self.GetFileName(int(effectFileName))
effectFullPathFileName = self.GetFullPathName(effectFileName)
chrmgr.RegisterEffect(chrmgr.EFFECT_STATE+int(effectType), "", effectFullPathFileName)
self.Print("effect state %d: %s" % (int(effectType), effectFullPathFileName))
def SetCharacterAffect(self, affectType, isVisible):
"Set character's affect (number, visiblity 1|0)"
chrmgr.SetAffect(-1, int(affectType), int(isVisible))
self.Print("affect set %d: %d" % (int(affectType), int(isVisible)))
def SetCharacterEmoticon(self, EmoticonNum):
"Show emoticon (number)"
chrmgr.SetEmoticon(-1, int(EmoticonNum))
self.Print("Emoticon %d: %d" % (int(EmoticonNum), int(isVisible)))
def ShowPickedCharacterInfo(self):
"Show information of picked character"
vid=chrmgr.GetPickedVID()
info=chrmgr.GetVIDInfo(vid)
self.Print(info)
def ShowCharacterInfo(self, arg):
"Show information of character (vid)"
if arg.isdigit():
vid=int(arg)
else:
vid=0
info=chrmgr.GetVIDInfo(vid)
self.Print(info)
def SetWeaponTraceTexture(self, arg):
"Sets sword afterimage texture (filename)"
if arg.isdigit():
textureFileName = self.GetFileName(int(arg))
else:
textureFileName = arg
chr.WeaponTraceSetTexture(textureFileName)
def SetAutoCameraRotationSpeed(self, arg):
"Auto camera rotation speed (angle per sec)"
spd=float(arg)
player.SetAutoCameraRotationSpeed(spd)
self.Print("Auto camera rotation speed: %f" % (spd))
def SetWeaponTraceMode(self, *mode):
"Sword afterimage mode (0 = Use alpha, 1 = Use texture)"
if mode and mode[0].isdigit() and int(mode[0]):
chr.WeaponTraceUseTexture()
else:
chr.WeaponTraceUseAlpha()
def SetCollision(self, *mode):
"Show collison objects (0 | 1)"
if mode and mode[0].isdigit():
self.collision = int(mode[0])
else:
self.collision = not self.collision
def SetMovingSpeed(self, arg):
"Set walking speed"
chrmgr.SetMovingSpeed(int(arg))
def SetMusicVolume(self, arg):
"Set BGM volumn (0 ~ 1.0)"
snd.SetMusicVolume(float(arg))
def SetSoundVolume(self, arg):
"Set Effect sound volumn (0 ~ 1.0)"
snd.SetSoundVolume(float(arg))
def SetSoundScale(self, arg):
"3D Sound scale (default : 200)"
snd.SetSoundScale(int(arg))
def SetAmbienceSoundScale(self, arg):
"3D Ambience sound scale (default : 200)"
snd.SetAmbienceSoundScale(int(arg))
def SetCoolTime(self):
"Cooltime toggle"
flag = player.ToggleCoolTime()
if flag:
self.Print("Cooltime will be applied")
else:
self.Print("Cooltime disabled")
def SetLevelLimit(self):
"Sets Level limit"
flag = player.ToggleLevelLimit()
if flag:
self.Print("Level limit will be applied")
else:
self.Print("Level limit disabled")
def ShowCursor(self):
app.ShowCursor()
def HideCursor(self):
app.HideCursor()
def Print(self, msg):
self.output.Print(msg)
def RefreshPath(self):
self.SetPath(self.curPathName)
def SetPath(self, newPathName):
if '\\'!=newPathName[-1]:
newPathName=newPathName+'\\'
if os.access(newPathName, os.R_OK)==0:
self.Print(newPathName+" Cannot find path")
return
nameList=os.listdir(newPathName)
dirNameList=[]
fileNameList=[]
for sName in nameList:
mode=os.stat(newPathName+sName)[stat.ST_MODE]
if stat.S_ISDIR(mode):
dirNameList.append(sName)
else:
fileNameList.append(sName)
self.curPathName=newPathName
self.dirNameList=dirNameList
self.fileNameList=fileNameList
self.ShowPath()
def GetPath(self):
return self.curPathName
def GetDirName(self, iDir):
if (len(self.dirNameList)>iDir):
return self.dirNameList[iDir]
else:
print((len(self.dirNameList)))
return ""
def GetFileName(self, iFile):
if (len(self.fileNameList)>iFile):
return self.fileNameList[iFile]
else:
print((len(self.fileNameList)))
return ""
def MoveParentPath(self):
"Go to Parent directory"
newPathName=self.GetPath()
lastPos=-1
if '\\'==newPathName[-1]:
lastPos=-2
lastPos=newPathName.rfind('\\', 0, lastPos)
if 0>lastPos:
self.Print("Here is root")
return
newPathName=newPathName[0:lastPos]+'\\'
self.SetPath(newPathName)
def GetFullPathName(self, sPathName):
sParentPathName=self.GetPath()
if '\\'!=sParentPathName[-1]:
sParentPathName=sParentPathName+'\\'
return sParentPathName+sPathName
def MoveChildPath(self, directory):
"[Directory name/number] change to child directory"
if ""==directory:
self.Print("You need directory name or number")
return
if directory.isdigit():
directory=self.GetDirName(int(directory))
newPathName=self.GetFullPathName(directory)
self.SetPath(newPathName)
def SetHitEffect(self, arg):
"Sets hit effect"
if arg.isdigit():
effectFileName = self.GetFileName(int(arg))
else:
effectFileName = arg
effectFullPathFileName=self.GetFullPathName(EffectFileName)
chrmgr.RegisterEffect(chrmgr.EFFECT_HIT, "", effectFullPathFileName)
self.Print("Hit effect: "+effectFullPathFileName)
def SetStunEffect(self, arg):
"Sets stun effect"
if arg.isdigit():
effectFileName = self.GetFileName(int(arg))
else:
effectFileName = arg
effectFullPathFileName = self.GetFullPathName(effectFileName)
chrmgr.RegisterEffect(chrmgr.EFFECT_STUN, "Bip01 Head", effectFullPathFileName)
self.Print("Stun effect: "+effectFullPathFileName)
def SetDustEffect(self, arg):
"Sets dirt effect"
if arg.isdigit():
effectFileName = self.GetFileName(int(arg))
else:
effectFileName = arg
effectFullPathFileName = self.GetFullPathName(effectFileName)
chrmgr.RegisterEffect(chrmgr.EFFECT_DUST, "", effectFullPathFileName)
self.Print("Dirt effect: "+effectFullPathFileName)
def SetDustGap(self, arg):
"Sets dirt effect gap"
if arg.isdigit() == 0:
self.Print("Dirt effect gap argument must be a number")
else:
gap = int(arg)
chrmgr.SetDustGap(gap)
self.Print("Dirt effect gap: %d" % (gap))
def ShowBackgroundPart(self, arg):
"Show background part"
try:
background.SetVisiblePart(self.bgPartDict[arg], 1);
except KeyError:
self.Print("Unknown part: ", arg);
except:
raise
def HideBackgroundPart(self, arg):
"Hide background part"
try:
background.SetVisiblePart(self.bgPartDict[arg], 0);
except KeyError:
self.Print("Unknown part: ", arg);
except:
raise
def SetShadowLevel(self, arg):
"Shadow level setting (0~5)"
if arg.isdigit() == 0:
self.Print("Shadow setting must be a number")
else:
level = int(arg)
if level < 0 or level > 5:
self.Print("Shadow level range is 0~5")
else:
background.SetShadowLevel(level)
self.Print("Shadow level: %d" % (level))
def SetSplatLimit(self, arg):
"Splat number limit"
if arg.isdigit() == 0:
self.Print("Splat number limit must be a number")
else:
limit = int(arg)
background.SetSplatLimit(limit)
self.Print("Splat number limit: %d" % (limit))
def SelectViewDistanceNum(self, arg):
"View distance (0~4)"
if arg.isdigit() == 0:
self.Print("Enter between 0 to 4")
else:
settingnum = int(arg)
if settingnum < 0 or settingnum > 4:
self.Print("View distance range is 0 to 4")
else:
background.SelectViewDistanceNum(settingnum)
self.Print("View distance: %d" % (settingnum))
def SetBGLoading(self, bBGLoading):
"Background loading (0, 1)"
bResultBoolean = int(bBGLoading)
if bResultBoolean != 0 and bResultBoolean != 1:
self.Print("Enter 0 or 1")
else:
background.SetBGLoading(bResultBoolean)
self.Print("Background loading: %d" % (bResultBoolean))
def SetTerrainRenderSort(self, arg):
"Terrain rendering type"
try:
background.SetRenderSort(self.bgSortDict[arg]);
except KeyError:
self.Print("Unknown part: ", arg);
except:
raise
def SetTransparentTree(self, arg):
"Tree's leaf transparency"
bTransparent = int(arg)
try:
background.SetTransparentTree(bTransparent);
except KeyError:
self.Print("must be 0 or 1: ", bTransparent);
except:
raise
def WarpTest(self, warpX, warpY):
"WarpTest : warp dwX dwY"
iWarpX = int(warpX)
iWarpY = int(warpY)
try:
background.Destroy()
background.Initialize()
background.WarpTest(iWarpX, iWarpY);
background.RegisterEnvironmentData(0, "d:/ymir work/environment/b3.msenv")
background.SetEnvironmentData(0)
background.SetShadowLevel(background.SHADOW_ALL)
except:
import exception
exception.Abort("consoleModule.Console.WarpTest")
def ToggleDebugInfo(self):
"Show DebugInfo"
net.ToggleGameDebugInfo()
def ShowPath(self):
"Show current path"
self.Print("Current path is "+self.GetPath())
def ShowList(self):
"Show current path's list"
self.ShowDirList()
self.ShowFileList()
def ShowDirList(self):
"Show current path's child directories"
self.Print(self.GetPath()+" directories:")
self.ShowNameList(self.dirNameList)
self.Print("")
def ShowFileList(self, Filter=[]):
"Show current path's files (extension filter)"
self.Print(self.GetPath()+" files:")
self.ShowNameList(self.fileNameList, Filter)
self.Print("")
def ShowEffectList(self):
"Show current path's effect"
self.Print(self.GetPath()+" effects:")
self.ShowNameList(self.fileNameList, ["mse"])
self.Print("")
def ShowWeb(self):
"ShowWeb"
if app.IsWebPageMode():
app.HideWebPage()
else:
app.ShowWebPage("http://wiki.metin.co.kr/metin1help/01.htm", (0, 0, 320, 600))
def ShowUI(self):
"Shows UI"
self.game.CheckGameButton()
self.game.interface.ShowDefaultWindows()
self.game.interface.wndChat.Show()
def HideUI(self):
"Hides UI"
self.game.interface.HideAllWindows()
self.game.interface.wndChat.Hide()
def SetCameraSpeed(self, percentage):
"Sets camera speed (Default = 100)"
app.SetCameraSpeed(int(percentage))
def SaveCameraSetting(self, filename):
"Save current camera attributes (filename)"
app.SaveCameraSetting(filename)
def LoadCameraSetting(self, filename):
"Load camera attributes (filename)"
if not app.LoadCameraSetting(filename):
self.Print("Could not load camera attribute")
def SetDefaultCamera(self):
"Return to default camera attribute"
app.SetDefaultCamera()
def ShowClock(self, second):
self.game.ShowClock(int(second))
def HideClock(self):
self.game.HideClock()
def ShowNotice(self):
app.SetVisibleNotice(TRUE)
self.Print("Show Notice")
def HideNotice(self):
app.SetVisibleNotice(FALSE)
self.Print("Hide Notice")
def SetSight(self, range):
"Set Force Sight Range"
app.SetSightRange(int(range))
def SetComboType(self, type):
chr.testSetComboType(int(type))
def SetSkillGroupFake(self, index):
"""테스트 코드"""
net.SetSkillGroupFake(int(index))
self.Print(" SetSkillGroupFake : %d" % int(index))
def SetEmpireLanguageMode(self, mode):
net.SetEmpireLanguageMode(int(mode))
self.Print(" SetEmpireLanguageMode : %d" % int(mode))
def SetCharacterRenderModeTypeAdd(self, color):
vid = player.GetTargetVID()
print((" -> SetCharacterRenderModeTypeAdd", vid, color))
chr.testSetAddRenderMode(vid, int(color,16))
def SetCharacterRenderModeTypeMod(self, color):
vid = player.GetTargetVID()
print((" -> SetCharacterRenderModeTypeMod", vid, color, int(color,16)))
chr.testSetModulateRenderMode(vid, int(color,16))
def SetCharacterRenderModeTypeAddRGB(self, r, g, b):
vid = player.GetTargetVID()
print((" -> SetCharacterRenderModeTypeAddRGB", vid, r, g, b))
chr.testSetAddRenderModeRGB(vid, float(r)/255.0, float(g)/255.0, float(b)/255.0)
def SetCharacterRenderModeTypeModRGB(self, r, g, b):
vid = player.GetTargetVID()
print((" -> SetCharacterRenderModeTypeModRGB", vid, r, g, b))
chr.testSetModulateRenderModeRGB(vid, float(r)/255.0, float(g)/255.0, float(b)/255.0)
def SetCharacterRenderModeSpecular(self, alpha):
vid = player.GetTargetVID()
print((" -> SetCharacterRenderModeSpecular", vid, alpha))
chr.testSetSpecularRenderMode(vid, float(alpha))
def RestoreCharacterRenderModeType(self):
vid = player.GetTargetVID()
chr.testRestoreRenderMode(vid)
def ShowNameList(self, lstsName, lstsFilter=None):
if len(lstsName)==0:
self.Print("None")
return
if lstsFilter:
isFilter=1
else:
isFilter=0
sLine=""
iCol=0
iName=0
for sName in lstsName:
if isFilter:
iDotPos=sName.rfind('.', 0, -1)
if iDotPos<0:
iName=iName+1
continue
if (sName[iDotPos+1:] in lstsFilter)==0:
iName=iName+1
continue
sLine=sLine+"%3d %-15s " % (iName, sName)
if iCol>4:
iCol=0
self.Print(sLine)
sLine=""
iCol=iCol+1
iName=iName+1
if ""!=sLine:
self.Print(sLine)
class ConsoleWindow(ui.Window):
BACK_GROUND_COLOR = grp.GenerateColor(0.0, 0.0, 0.0, 0.5)
EDIT_LINE_COLOR = grp.GenerateColor(0.0, 0.0, 0.0, 1.0)
BUTTON_COLOR = grp.GenerateColor(1.0, 1.0, 1.0, 1.0)
HEIGHT = 200
LINE_STEP = 15
MAX_LINE_COUNT = 50
class ConsoleEditLine(ui.EditLine):
def __init__(self):
ui.EditLine.__init__(self)
self.eventReturn = 0
self.eventEscape = 0
def __del__(self):
ui.EditLine.__del__(self)
def SetReturnEvent(self, event):
self.eventReturn = event
def SetEscapeEvent(self, event):
self.eventEscape = event
def OnIMEReturn(self):
text = self.GetText()
if len(text) > 0:
self.eventReturn(text)
else:
wndMgr.KillFocus()
self.eventEscape()
self.SetText("")
return TRUE
def OnPressEscapeKey(self):
self.SetText("")
wndMgr.KillFocus()
self.eventEscape()
return TRUE
class ResizingButton(ui.DragButton):
BUTTON_NORMAL_COLOR = grp.GenerateColor(0.3320, 0.2929, 0.2578, 1.0)
BUTTON_OVER_COLOR = grp.GenerateColor(0.5320, 0.4929, 0.4578, 1.0)
BUTTON_LIGHT_OUTLINE_COLOR = grp.GenerateColor(0.6666, 0.6509, 0.6313, 1.0)
BUTTON_DARK_OUTLINE_COLOR = grp.GenerateColor(0.1647, 0.1450, 0.1294, 1.0)
def __init__(self):
ui.DragButton.__init__(self)
self.AddFlag("limit")
self.AddFlag("restrict_x")
def __del__(self):
ui.DragButton.__del__(self)
def __init__(self):
ui.Window.__init__(self)
self.TextList = []
self.game = 0
self.Console = Console(self)
self.ResizingButton = self.ResizingButton()
self.ResizingButton.SetParent(self)
self.ResizingButton.SetSize(15, 15)
self.ResizingButton.SetPosition(100, 100)
self.ResizingButton.Show()
self.EditLine = self.ConsoleEditLine()
self.EditLine.SetParent(self)
self.EditLine.SetMax(100)
self.EditLine.SetFontName(localeInfo.UI_DEF_FONT)
self.EditLine.SetText("")
self.EditLine.Show()
from _weakref import ref
self.ResizingButton.SetMoveEvent(lambda s = ref(self): s().UpdatePosition())
self.EditLine.SetReturnEvent(lambda x,s = ref(self): s().ProcessCommand(x))
self.EditLine.SetEscapeEvent(lambda s = ref(self): s().CloseWindow())
self.UpdatePosition()
self.functionDict = {}
self.InitFunction()
def __del__(self):
ui.Window.__del__(self)
def BindGameClass(self, game):
self.Console.BindGameClass(game)
def Close(self):
self.Console.Close()
self.ResizingButton = 0
self.EditLine = 0
def SetConsoleSize(self, width, height):
self.ResizingButton.SetPosition(width-20, height-20)
self.UpdatePosition()
def OnRender(self):
grp.SetColor(self.BACK_GROUND_COLOR)
grp.RenderBar(self.gx, self.gy, self.width, self.height)
grp.SetColor(ConsoleWindow.EDIT_LINE_COLOR)
grp.RenderBar(self.gxEditLine-2, self.gyEditLine-3, self.width - 40, 17)
grp.SetColor(ConsoleWindow.BUTTON_COLOR)
grp.RenderBar(self.gxButton-2, self.gyButton-3, self.widthButton, self.heightButton)
def UpdatePosition(self):
self.width = self.GetWidth()
self.height = self.GetHeight()
self.widthButton = self.ResizingButton.GetWidth()
self.heightButton = self.ResizingButton.GetHeight()
(self.gx, self.gy) = self.GetGlobalPosition()
(self.gxButton, self.gyButton) = self.ResizingButton.GetGlobalPosition()
self.SetSize(self.gxButton - self.gx + 20, self.gyButton - self.gy + 20)
self.EditLine.SetSize(self.width-30, 16)
self.EditLine.SetPosition(7, self.height-20)
(self.gxEditLine, self.gyEditLine) = self.EditLine.GetGlobalPosition()
#####
yPosition = (self.height-20) - self.LINE_STEP
ItemCount = len(self.TextList)
for i in range(ItemCount):
TextLine = self.TextList[ItemCount-i-1]
TextLine.SetPosition(10, yPosition)
yPosition -= self.LINE_STEP
if yPosition < 0:
TextLine.Hide()
else:
TextLine.Show()
def OpenWindow(self):
self.EditLine.SetFocus()
self.Show()
self.Console.RefreshPath()
def CloseWindow(self):
self.Hide()
## NOTE : 이곳에서 Command를 처리합니다 - [levites]
def ProcessCommand(self, text):
if '/' == text[0]:
net.SendChatPacket(text)
return
Console=self.Console
Console.Print(">> "+text)
lstsArg=text.split()
if len(lstsArg)==0:
return
sCmd=lstsArg[0]
if sCmd in self.functionDict:
try:
self.functionDict[sCmd](self.Console, *lstsArg[1:])
except Exception as e:
Console.Print(str(e))
#self.Console.Print(e)
#self.Console.Print(self.functionDict[sCmd].__doc__)
else:
if sCmd == 'help' or sCmd == 'h':
try:
k = lstsArg[1]
v = self.functionDict[k]
argcount = v.__func__.__code__.co_argcount - 1 # -1 for self
if v.__func__.__code__.co_flags & 4:
argcount+=1
argnames = v.__func__.__code__.co_varnames[1:argcount+1]
if argcount:
Console.Print("%s(%s) : %s" % (k,argcount, v.__doc__))
Console.Print(" arg : %s" % argnames)
else:
Console.Print("%s : %s" % (k,v.__doc__))
except:
for k,v in list(self.functionDict.items()):
argcount = v.__func__.__code__.co_argcount - 1 # -1 for self
if v.__func__.__code__.co_flags & 4:
argcount+=1
if argcount:
Console.Print("%s(%s) : %s" % (k,argcount, v.__doc__))
else:
Console.Print("%s : %s" % (k,v.__doc__))
Console.Print("? : All commands list")
Console.Print("h : Help for all commands")
Console.Print("h blah : Help for blah")
Console.Print("")
elif sCmd == '?':
list = list(self.functionDict.keys())
list.sort()
Console.ShowNameList(list)
pass
def InitFunction(self):
#self.AddFunction("help", Console.PrintHelp)
#self.AddFunction("?", Console.PrintHelp)
self.AddFunction("exit", Console.Exit)
self.AddFunction("mvol", Console.SetMusicVolume)
self.AddFunction("svol", Console.SetSoundVolume)
self.AddFunction("snds", Console.SetSoundScale)
self.AddFunction("asnds", Console.SetAmbienceSoundScale)
self.AddFunction("mspd", Console.SetMovingSpeed)
self.AddFunction("pwd", Console.ShowPath)
self.AddFunction("ls", Console.ShowList)
self.AddFunction("shadow", Console.SetShadowLevel)
self.AddFunction("splat", Console.SetSplatLimit)
self.AddFunction("distance", Console.SelectViewDistanceNum)
self.AddFunction("bgloading", Console.SetBGLoading)
self.AddFunction("terrainrender", Console.SetTerrainRenderSort)
self.AddFunction("transtree", Console.SetTransparentTree)
self.AddFunction("stune", Console.SetStunEffect)
self.AddFunction("duste", Console.SetDustEffect)
self.AddFunction("dustt", Console.SetDustGap)
self.AddFunction("hite", Console.SetHitEffect)
self.AddFunction("cd", Console.MoveChildPath)
self.AddFunction("up", Console.MoveParentPath)
self.AddFunction("lsd", Console.ShowDirList)
self.AddFunction("lsf", Console.ShowFileList)
self.AddFunction("lse", Console.ShowEffectList)
self.AddFunction("show", Console.ShowBackgroundPart)
self.AddFunction("hide", Console.HideBackgroundPart)
self.AddFunction("debuginfo", Console.ToggleDebugInfo)
self.AddFunction("collision", Console.SetCollision)
self.AddFunction("colli", Console.SetCollision)
#self.AddFunction("wt", Console.SetWeaponTrace)
self.AddFunction("wtt", Console.SetWeaponTraceTexture)
self.AddFunction("wtm", Console.SetWeaponTraceMode)
self.AddFunction("disconnect", Console.Disconnect)
self.AddFunction("autorot", Console.SetAutoCameraRotationSpeed)
self.AddFunction("dirline", Console.ToggleActorDirectionLine)
self.AddFunction("pickc", Console.ShowPickedCharacterInfo)
self.AddFunction("infoc", Console.ShowCharacterInfo)
self.AddFunction("regchre", Console.RegisterCharacterEffect)
self.AddFunction("setchra", Console.SetCharacterAffect)
self.AddFunction("emoticon", Console.SetCharacterEmoticon)
self.AddFunction("perfinfo", Console.ShowPerformanceInfo)
self.AddFunction("reload_locale", Console.ReloadLocale)
self.AddFunction("re", Console.ReloadDevel)
self.AddFunction("perftime", Console.EnablePerformanceTime)
self.AddFunction("cooltime", Console.SetCoolTime)
self.AddFunction("levellimit", Console.SetLevelLimit)
self.AddFunction("showcursor", Console.ShowCursor)
self.AddFunction("hidecursor", Console.HideCursor)
self.AddFunction("warp", Console.WarpTest)
self.AddFunction("web", Console.ShowWeb)
self.AddFunction("showui", Console.ShowUI)
self.AddFunction("hideui", Console.HideUI)
self.AddFunction("setcspd", Console.SetCameraSpeed)
self.AddFunction("savecmr", Console.SaveCameraSetting)
self.AddFunction("loadcmr", Console.LoadCameraSetting)
self.AddFunction("setdefcmr", Console.SetDefaultCamera)
self.AddFunction("showclock", Console.ShowClock)
self.AddFunction("hideclock", Console.HideClock)
self.AddFunction("setsight", Console.SetSight)
self.AddFunction("setcombotype", Console.SetComboType)
self.AddFunction("setsk_fake", Console.SetSkillGroupFake)
self.AddFunction("trans", Console.SetEmpireLanguageMode)
self.AddFunction("shownotice", Console.ShowNotice)
self.AddFunction("hidenotice", Console.HideNotice)
self.AddFunction("setrmadd", Console.SetCharacterRenderModeTypeAdd)
self.AddFunction("setrmmod", Console.SetCharacterRenderModeTypeMod)
self.AddFunction("setrmaddrgb", Console.SetCharacterRenderModeTypeAddRGB)
self.AddFunction("setrmmodrgb", Console.SetCharacterRenderModeTypeModRGB)
self.AddFunction("setspec", Console.SetCharacterRenderModeSpecular)
self.AddFunction("restorerm", Console.RestoreCharacterRenderModeType)
def AddFunction(self, cmd, func):
self.functionDict[cmd] = func
def Print(self, text):
TextLine = ui.TextLine()
TextLine.SetParent(self)
TextLine.SetFontName(localeInfo.UI_DEF_FONT)
TextLine.Show()
TextLine.SetText(text)
self.TextList.append(TextLine)
count = len(self.TextList)
if count > self.MAX_LINE_COUNT:
for i in range(count - self.MAX_LINE_COUNT):
del self.TextList[0]
self.UpdatePosition()
-250
View File
@@ -1,250 +0,0 @@
# option
CONSOLE_ENABLE = 0
PVPMODE_ENABLE = 1
PVPMODE_TEST_ENABLE = 0
PVPMODE_ACCELKEY_ENABLE = 1
PVPMODE_ACCELKEY_DELAY = 0.5
PVPMODE_PROTECTED_LEVEL = 30
FOG_LEVEL0 = 4800.0
FOG_LEVEL1 = 9600.0
FOG_LEVEL2 = 12800.0
FOG_LEVEL = FOG_LEVEL0
FOG_LEVEL_LIST = [FOG_LEVEL0, FOG_LEVEL1, FOG_LEVEL2]
CAMERA_MAX_DISTANCE_SHORT = 2500.0
CAMERA_MAX_DISTANCE_LONG = 3500.0
CAMERA_MAX_DISTANCE_LIST = [CAMERA_MAX_DISTANCE_SHORT, CAMERA_MAX_DISTANCE_LONG]
CAMERA_MAX_DISTANCE = CAMERA_MAX_DISTANCE_SHORT
CHRNAME_COLOR_INDEX = 0
ENVIRONMENT_NIGHT = "d:/ymir work/environment/moonlight04.msenv"
# constant
HIGH_PRICE = 500000
MIDDLE_PRICE = 50000
ERROR_METIN_STONE = 28960
SUB2_LOADING_ENABLE = 1
EXPANDED_COMBO_ENABLE = 1
CONVERT_EMPIRE_LANGUAGE_ENABLE = 1
USE_ITEM_WEAPON_TABLE_ATTACK_BONUS = 0
ADD_DEF_BONUS_ENABLE = 1
LOGIN_COUNT_LIMIT_ENABLE = 0
USE_SKILL_EFFECT_UPGRADE_ENABLE = 1
VIEW_OTHER_EMPIRE_PLAYER_TARGET_BOARD = 1
GUILD_MONEY_PER_GSP = 100
GUILD_WAR_TYPE_SELECT_ENABLE = 1
TWO_HANDED_WEAPON_ATT_SPEED_DECREASE_VALUE = 0
HAIR_COLOR_ENABLE = 1
ARMOR_SPECULAR_ENABLE = 1
WEAPON_SPECULAR_ENABLE = 1
KEEP_ACCOUNT_CONNETION_ENABLE = 1
MINIMAP_POSITIONINFO_ENABLE = 0
CONVERT_EMPIRE_LANGUAGE_ENABLE = 0
USE_ITEM_WEAPON_TABLE_ATTACK_BONUS = 0
ADD_DEF_BONUS_ENABLE = 0
LOGIN_COUNT_LIMIT_ENABLE = 0
PVPMODE_PROTECTED_LEVEL = 15
TWO_HANDED_WEAPON_ATT_SPEED_DECREASE_VALUE = 10
# MR-3: Define max quickslot slots number for scripts
QUICKSLOT_MAX_NUM = 36
# MR-3: -- END OF -- Define max quickslot slots number for scripts
isItemQuestionDialog = 0
def GET_ITEM_QUESTION_DIALOG_STATUS():
global isItemQuestionDialog
return isItemQuestionDialog
def SET_ITEM_QUESTION_DIALOG_STATUS(flag):
global isItemQuestionDialog
isItemQuestionDialog = flag
import app
import net
# MR-10: Add accessorySocketTimeCache for real-time remaining time display of accessory sockets.
# Cache for accessory/belt socket timers so they persist across UI reloads.
if not hasattr(app, "_accessorySocketTimeCache"):
app._accessorySocketTimeCache = {}
ACCESSORY_SOCKET_TIME_CACHE = app._accessorySocketTimeCache
# MR-10: -- END OF -- Add accessorySocketTimeCache for real-time remaining time display of accessory sockets.
########################
def SET_DEFAULT_FOG_LEVEL():
global FOG_LEVEL
app.SetMinFog(FOG_LEVEL)
def SET_FOG_LEVEL_INDEX(index):
global FOG_LEVEL
global FOG_LEVEL_LIST
try:
FOG_LEVEL=FOG_LEVEL_LIST[index]
except IndexError:
FOG_LEVEL=FOG_LEVEL_LIST[0]
app.SetMinFog(FOG_LEVEL)
def GET_FOG_LEVEL_INDEX():
global FOG_LEVEL
global FOG_LEVEL_LIST
return FOG_LEVEL_LIST.index(FOG_LEVEL)
########################
def SET_DEFAULT_CAMERA_MAX_DISTANCE():
global CAMERA_MAX_DISTANCE
app.SetCameraMaxDistance(CAMERA_MAX_DISTANCE)
def SET_CAMERA_MAX_DISTANCE_INDEX(index):
global CAMERA_MAX_DISTANCE
global CAMERA_MAX_DISTANCE_LIST
try:
CAMERA_MAX_DISTANCE=CAMERA_MAX_DISTANCE_LIST[index]
except:
CAMERA_MAX_DISTANCE=CAMERA_MAX_DISTANCE_LIST[0]
app.SetCameraMaxDistance(CAMERA_MAX_DISTANCE)
def GET_CAMERA_MAX_DISTANCE_INDEX():
global CAMERA_MAX_DISTANCE
global CAMERA_MAX_DISTANCE_LIST
return CAMERA_MAX_DISTANCE_LIST.index(CAMERA_MAX_DISTANCE)
########################
import chrmgr
import player
import app
def SET_DEFAULT_CHRNAME_COLOR():
global CHRNAME_COLOR_INDEX
chrmgr.SetEmpireNameMode(CHRNAME_COLOR_INDEX)
def SET_CHRNAME_COLOR_INDEX(index):
global CHRNAME_COLOR_INDEX
CHRNAME_COLOR_INDEX=index
chrmgr.SetEmpireNameMode(index)
def GET_CHRNAME_COLOR_INDEX():
global CHRNAME_COLOR_INDEX
return CHRNAME_COLOR_INDEX
def SET_VIEW_OTHER_EMPIRE_PLAYER_TARGET_BOARD(index):
global VIEW_OTHER_EMPIRE_PLAYER_TARGET_BOARD
VIEW_OTHER_EMPIRE_PLAYER_TARGET_BOARD = index
def GET_VIEW_OTHER_EMPIRE_PLAYER_TARGET_BOARD():
global VIEW_OTHER_EMPIRE_PLAYER_TARGET_BOARD
return VIEW_OTHER_EMPIRE_PLAYER_TARGET_BOARD
def SET_DEFAULT_CONVERT_EMPIRE_LANGUAGE_ENABLE():
global CONVERT_EMPIRE_LANGUAGE_ENABLE
net.SetEmpireLanguageMode(CONVERT_EMPIRE_LANGUAGE_ENABLE)
def SET_DEFAULT_USE_ITEM_WEAPON_TABLE_ATTACK_BONUS():
global USE_ITEM_WEAPON_TABLE_ATTACK_BONUS
player.SetWeaponAttackBonusFlag(USE_ITEM_WEAPON_TABLE_ATTACK_BONUS)
def SET_DEFAULT_USE_SKILL_EFFECT_ENABLE():
global USE_SKILL_EFFECT_UPGRADE_ENABLE
app.SetSkillEffectUpgradeEnable(USE_SKILL_EFFECT_UPGRADE_ENABLE)
def SET_TWO_HANDED_WEAPON_ATT_SPEED_DECREASE_VALUE():
global TWO_HANDED_WEAPON_ATT_SPEED_DECREASE_VALUE
app.SetTwoHandedWeaponAttSpeedDecreaseValue(TWO_HANDED_WEAPON_ATT_SPEED_DECREASE_VALUE)
########################
import item
ACCESSORY_MATERIAL_LIST = [50623, 50624, 50625, 50626, 50627, 50628, 50629, 50630, 50631, 50632, 50633, 50634, 50635, 50636, 50637, 50638]
#ACCESSORY_MATERIAL_LIST = [50623, 50623, 50624, 50624, 50625, 50625, 50626, 50627, 50628, 50629, 50630, 50631, 50632, 50633,
# 50623, 50623, 50624, 50624, ]
JewelAccessoryInfos = [
# jewel wrist neck ear
[ 50634, 14420, 16220, 17220 ],
[ 50635, 14500, 16500, 17500 ],
[ 50636, 14520, 16520, 17520 ],
[ 50637, 14540, 16540, 17540 ],
[ 50638, 14560, 16560, 17560 ],
]
def GET_ACCESSORY_MATERIAL_VNUM(vnum, subType):
ret = vnum
item_base = (vnum // 10) * 10
for info in JewelAccessoryInfos:
if item.ARMOR_WRIST == subType:
if info[1] == item_base:
return info[0]
elif item.ARMOR_NECK == subType:
if info[2] == item_base:
return info[0]
elif item.ARMOR_EAR == subType:
if info[3] == item_base:
return info[0]
if vnum >= 16210 and vnum <= 16219:
return 50625
if item.ARMOR_WRIST == subType:
WRIST_ITEM_VNUM_BASE = 14000
ret -= WRIST_ITEM_VNUM_BASE
elif item.ARMOR_NECK == subType:
NECK_ITEM_VNUM_BASE = 16000
ret -= NECK_ITEM_VNUM_BASE
elif item.ARMOR_EAR == subType:
EAR_ITEM_VNUM_BASE = 17000
ret -= EAR_ITEM_VNUM_BASE
type = ret // 20
if type < 0 or type >= len(ACCESSORY_MATERIAL_LIST):
type = (ret - 170) // 20
if type < 0 or type >= len(ACCESSORY_MATERIAL_LIST):
return 0
return ACCESSORY_MATERIAL_LIST[type]
##################################################################
## Belt item type and belt socket item handling
## Belt socket system is identical to accessories, so must use hardcoding approach similar to accessory handling
def GET_BELT_MATERIAL_VNUM(vnum, subType = 0):
# Currently all belts can only insert one item type (#18900)
return 18900
##################################################################
## Auto-potions (HP: #72723 ~ #72726, SP: #72727 ~ #72730)
# Check if vnum is an auto-potion
def IS_AUTO_POTION(itemVnum):
return IS_AUTO_POTION_HP(itemVnum) or IS_AUTO_POTION_SP(itemVnum)
# Check if vnum is an HP auto-potion
def IS_AUTO_POTION_HP(itemVnum):
if 72723 <= itemVnum and 72726 >= itemVnum:
return 1
elif itemVnum >= 76021 and itemVnum <= 76022: ## Gift item: Fire Dragon's Blessing
return 1
elif itemVnum == 79012:
return 1
return 0
# Check if vnum is an SP auto-potion
def IS_AUTO_POTION_SP(itemVnum):
if 72727 <= itemVnum and 72730 >= itemVnum:
return 1
elif itemVnum >= 76004 and itemVnum <= 76005: ## Gift item: Water Dragon's Blessing
return 1
elif itemVnum == 79013:
return 1
return 0
-10
View File
@@ -1,10 +0,0 @@
g_isDebugMode=0
def SetDebugMode(isDebugMode):
global g_isDebugMode
g_isDebugMode=isDebugMode
def IsDebugMode():
global g_isDebugMode
return g_isDebugMode
-47
View File
@@ -1,47 +0,0 @@
import item
# default_grade_need_count = [3, 3, 3, 3]
default_grade_need_count = [15, 10, 5, 3]
default_grade_fee = [30000, 50000, 70000, 100000]
default_step_need_count = [4, 3, 2, 1]
default_step_fee = [20000, 30000, 40000, 50000]
strength_fee = {
item.MATERIAL_DS_REFINE_NORMAL : 10000,
item.MATERIAL_DS_REFINE_BLESSED : 20000,
item.MATERIAL_DS_REFINE_HOLLY : 30000,
}
# Maximum strength value for each grade and step of refinement
# table(GRADE, STEP) = max strength.
default_strength_max_table = [
[2, 2, 3, 3, 4],
[3, 3, 3, 4, 4],
[4, 4, 4, 4, 4],
[4, 4, 4, 4, 5],
[4, 4, 4, 5, 6],
]
# For the current plan, strength enhancement is excluded, and enhancement fee is not determined yet,
# so it is not added to dragon_soul_refine_info.
# (Even if enhancement data exists, we want to be able to exclude it if needed)
# If you want to set different enhancement fees for different dragon soul types in other servers,
# and if you want different enhancement fees for each dragon soul type,
# you need to modify the client code.
default_refine_info = {
"grade_need_count" : default_grade_need_count,
"grade_fee" : default_grade_fee,
"step_need_count" : default_step_need_count,
"step_fee" : default_step_fee,
"strength_max_table" : default_strength_max_table,
}
dragon_soul_refine_info = {
11 : default_refine_info,
12 : default_refine_info,
13 : default_refine_info,
14 : default_refine_info,
15 : default_refine_info,
16 : default_refine_info,
}
-263
View File
@@ -1,263 +0,0 @@
import localeInfo
import player
import chrmgr
import chr
EMOTION_VERSION = 2
if EMOTION_VERSION == 2:
EMOTION_CLAP = 1
EMOTION_CONGRATULATION = 2
EMOTION_FORGIVE = 3
EMOTION_ANGRY = 4
EMOTION_ATTRACTIVE = 5
EMOTION_SAD = 6
EMOTION_SHY = 7
EMOTION_CHEERUP = 8
EMOTION_BANTER = 9
EMOTION_JOY = 10
EMOTION_CHEERS_1 = 11
EMOTION_CHEERS_2 = 12
EMOTION_DANCE_1 = 13
EMOTION_DANCE_2 = 14
EMOTION_DANCE_3 = 15
EMOTION_DANCE_4 = 16
EMOTION_DANCE_5 = 17
EMOTION_DANCE_6 = 18
EMOTION_KISS = 51
EMOTION_FRENCH_KISS = 52
EMOTION_SLAP = 53
EMOTION_DICT = {}
ICON_DICT = {
EMOTION_CLAP : "d:/ymir work/ui/game/windows/emotion_clap.sub",
EMOTION_CHEERS_1 : "d:/ymir work/ui/game/windows/emotion_cheers_1.sub",
EMOTION_CHEERS_2 : "d:/ymir work/ui/game/windows/emotion_cheers_2.sub",
EMOTION_DANCE_1 : "icon/action/dance1.tga",
EMOTION_DANCE_2 : "icon/action/dance2.tga",
EMOTION_CONGRATULATION : "icon/action/congratulation.tga",
EMOTION_FORGIVE : "icon/action/forgive.tga",
EMOTION_ANGRY : "icon/action/angry.tga",
EMOTION_ATTRACTIVE : "icon/action/attractive.tga",
EMOTION_SAD : "icon/action/sad.tga",
EMOTION_SHY : "icon/action/shy.tga",
EMOTION_CHEERUP : "icon/action/cheerup.tga",
EMOTION_BANTER : "icon/action/banter.tga",
EMOTION_JOY : "icon/action/joy.tga",
EMOTION_DANCE_1 : "icon/action/dance1.tga",
EMOTION_DANCE_2 : "icon/action/dance2.tga",
EMOTION_DANCE_3 : "icon/action/dance3.tga",
EMOTION_DANCE_4 : "icon/action/dance4.tga",
EMOTION_DANCE_5 : "icon/action/dance5.tga",
EMOTION_DANCE_6 : "icon/action/dance6.tga",
EMOTION_KISS : "d:/ymir work/ui/game/windows/emotion_kiss.sub",
EMOTION_FRENCH_KISS : "d:/ymir work/ui/game/windows/emotion_french_kiss.sub",
EMOTION_SLAP : "d:/ymir work/ui/game/windows/emotion_slap.sub",
}
ANI_DICT = {
chr.MOTION_CLAP : "clap.msa",
chr.MOTION_CHEERS_1 : "cheers_1.msa",
chr.MOTION_CHEERS_2 : "cheers_2.msa",
chr.MOTION_DANCE_1 : "dance_1.msa",
chr.MOTION_DANCE_2 : "dance_2.msa",
chr.MOTION_DANCE_3 : "dance_3.msa",
chr.MOTION_DANCE_4 : "dance_4.msa",
chr.MOTION_DANCE_5 : "dance_5.msa",
chr.MOTION_DANCE_6 : "dance_6.msa",
chr.MOTION_CONGRATULATION : "congratulation.msa",
chr.MOTION_FORGIVE : "forgive.msa",
chr.MOTION_ANGRY : "angry.msa",
chr.MOTION_ATTRACTIVE : "attractive.msa",
chr.MOTION_SAD : "sad.msa",
chr.MOTION_SHY : "shy.msa",
chr.MOTION_CHEERUP : "cheerup.msa",
chr.MOTION_BANTER : "banter.msa",
chr.MOTION_JOY : "joy.msa",
chr.MOTION_FRENCH_KISS_WITH_WARRIOR : "french_kiss_with_warrior.msa",
chr.MOTION_FRENCH_KISS_WITH_ASSASSIN : "french_kiss_with_assassin.msa",
chr.MOTION_FRENCH_KISS_WITH_SURA : "french_kiss_with_sura.msa",
chr.MOTION_FRENCH_KISS_WITH_SHAMAN : "french_kiss_with_shaman.msa",
chr.MOTION_KISS_WITH_WARRIOR : "kiss_with_warrior.msa",
chr.MOTION_KISS_WITH_ASSASSIN : "kiss_with_assassin.msa",
chr.MOTION_KISS_WITH_SURA : "kiss_with_sura.msa",
chr.MOTION_KISS_WITH_SHAMAN : "kiss_with_shaman.msa",
chr.MOTION_SLAP_HIT_WITH_WARRIOR : "slap_hit.msa",
chr.MOTION_SLAP_HIT_WITH_ASSASSIN : "slap_hit.msa",
chr.MOTION_SLAP_HIT_WITH_SURA : "slap_hit.msa",
chr.MOTION_SLAP_HIT_WITH_SHAMAN : "slap_hit.msa",
chr.MOTION_SLAP_HURT_WITH_WARRIOR : "slap_hurt.msa",
chr.MOTION_SLAP_HURT_WITH_ASSASSIN : "slap_hurt.msa",
chr.MOTION_SLAP_HURT_WITH_SURA : "slap_hurt.msa",
chr.MOTION_SLAP_HURT_WITH_SHAMAN : "slap_hurt.msa",
}
elif EMOTION_VERSION == 1:
EMOTION_CLAP = 1
EMOTION_CHEERS_1 = 2
EMOTION_CHEERS_2 = 3
EMOTION_DANCE_1 = 4
EMOTION_DANCE_2 = 5
EMOTION_KISS = 51
EMOTION_FRENCH_KISS = 52
EMOTION_SLAP = 53
EMOTION_DICT = {}
ICON_DICT = {
EMOTION_CLAP : "d:/ymir work/ui/game/windows/emotion_clap.sub",
EMOTION_CHEERS_1 : "d:/ymir work/ui/game/windows/emotion_cheers_1.sub",
EMOTION_CHEERS_2 : "d:/ymir work/ui/game/windows/emotion_cheers_2.sub",
EMOTION_DANCE_1 : "icon/action/dance1.tga",
EMOTION_DANCE_2 : "icon/action/dance2.tga",
EMOTION_KISS : "d:/ymir work/ui/game/windows/emotion_kiss.sub",
EMOTION_FRENCH_KISS : "d:/ymir work/ui/game/windows/emotion_french_kiss.sub",
EMOTION_SLAP : "d:/ymir work/ui/game/windows/emotion_slap.sub",
}
ANI_DICT = {
chr.MOTION_CLAP : "clap.msa",
chr.MOTION_CHEERS_1 : "cheers_1.msa",
chr.MOTION_CHEERS_2 : "cheers_2.msa",
chr.MOTION_DANCE_1 : "dance_1.msa",
chr.MOTION_DANCE_2 : "dance_2.msa",
chr.MOTION_FRENCH_KISS_WITH_WARRIOR : "french_kiss_with_warrior.msa",
chr.MOTION_FRENCH_KISS_WITH_ASSASSIN : "french_kiss_with_assassin.msa",
chr.MOTION_FRENCH_KISS_WITH_SURA : "french_kiss_with_sura.msa",
chr.MOTION_FRENCH_KISS_WITH_SHAMAN : "french_kiss_with_shaman.msa",
chr.MOTION_KISS_WITH_WARRIOR : "kiss_with_warrior.msa",
chr.MOTION_KISS_WITH_ASSASSIN : "kiss_with_assassin.msa",
chr.MOTION_KISS_WITH_SURA : "kiss_with_sura.msa",
chr.MOTION_KISS_WITH_SHAMAN : "kiss_with_shaman.msa",
chr.MOTION_SLAP_HIT_WITH_WARRIOR : "slap_hit.msa",
chr.MOTION_SLAP_HIT_WITH_ASSASSIN : "slap_hit.msa",
chr.MOTION_SLAP_HIT_WITH_SURA : "slap_hit.msa",
chr.MOTION_SLAP_HIT_WITH_SHAMAN : "slap_hit.msa",
chr.MOTION_SLAP_HURT_WITH_WARRIOR : "slap_hurt.msa",
chr.MOTION_SLAP_HURT_WITH_ASSASSIN : "slap_hurt.msa",
chr.MOTION_SLAP_HURT_WITH_SURA : "slap_hurt.msa",
chr.MOTION_SLAP_HURT_WITH_SHAMAN : "slap_hurt.msa",
}
else:
EMOTION_CLAP = 1
EMOTION_CHEERS_1 = 2
EMOTION_CHEERS_2 = 3
EMOTION_KISS = 51
EMOTION_FRENCH_KISS = 52
EMOTION_SLAP = 53
EMOTION_DICT = {}
ICON_DICT = {
EMOTION_CLAP : "d:/ymir work/ui/game/windows/emotion_clap.sub",
EMOTION_CHEERS_1 : "d:/ymir work/ui/game/windows/emotion_cheers_1.sub",
EMOTION_CHEERS_2 : "d:/ymir work/ui/game/windows/emotion_cheers_2.sub",
EMOTION_KISS : "d:/ymir work/ui/game/windows/emotion_kiss.sub",
EMOTION_FRENCH_KISS : "d:/ymir work/ui/game/windows/emotion_french_kiss.sub",
EMOTION_SLAP : "d:/ymir work/ui/game/windows/emotion_slap.sub",
}
ANI_DICT = {
chr.MOTION_CLAP : "clap.msa",
chr.MOTION_CHEERS_1 : "cheers_1.msa",
chr.MOTION_CHEERS_2 : "cheers_2.msa",
chr.MOTION_FRENCH_KISS_WITH_WARRIOR : "french_kiss_with_warrior.msa",
chr.MOTION_FRENCH_KISS_WITH_ASSASSIN : "french_kiss_with_assassin.msa",
chr.MOTION_FRENCH_KISS_WITH_SURA : "french_kiss_with_sura.msa",
chr.MOTION_FRENCH_KISS_WITH_SHAMAN : "french_kiss_with_shaman.msa",
chr.MOTION_KISS_WITH_WARRIOR : "kiss_with_warrior.msa",
chr.MOTION_KISS_WITH_ASSASSIN : "kiss_with_assassin.msa",
chr.MOTION_KISS_WITH_SURA : "kiss_with_sura.msa",
chr.MOTION_KISS_WITH_SHAMAN : "kiss_with_shaman.msa",
chr.MOTION_SLAP_HIT_WITH_WARRIOR : "slap_hit.msa",
chr.MOTION_SLAP_HIT_WITH_ASSASSIN : "slap_hit.msa",
chr.MOTION_SLAP_HIT_WITH_SURA : "slap_hit.msa",
chr.MOTION_SLAP_HIT_WITH_SHAMAN : "slap_hit.msa",
chr.MOTION_SLAP_HURT_WITH_WARRIOR : "slap_hurt.msa",
chr.MOTION_SLAP_HURT_WITH_ASSASSIN : "slap_hurt.msa",
chr.MOTION_SLAP_HURT_WITH_SURA : "slap_hurt.msa",
chr.MOTION_SLAP_HURT_WITH_SHAMAN : "slap_hurt.msa",
}
def _RebuildLocaleStrings():
global EMOTION_DICT
if EMOTION_VERSION == 2:
EMOTION_DICT = {
EMOTION_CLAP : {"name": localeInfo.EMOTION_CLAP, "command":"/clap"},
EMOTION_DANCE_1 : {"name": localeInfo.EMOTION_DANCE_1, "command":"/dance1"},
EMOTION_DANCE_2 : {"name": localeInfo.EMOTION_DANCE_2, "command":"/dance2"},
EMOTION_DANCE_3 : {"name": localeInfo.EMOTION_DANCE_3, "command":"/dance3"},
EMOTION_DANCE_4 : {"name": localeInfo.EMOTION_DANCE_4, "command":"/dance4"},
EMOTION_DANCE_5 : {"name": localeInfo.EMOTION_DANCE_5, "command":"/dance5"},
EMOTION_DANCE_6 : {"name": localeInfo.EMOTION_DANCE_6, "command":"/dance6"},
EMOTION_CONGRATULATION : {"name": localeInfo.EMOTION_CONGRATULATION, "command":"/congratulation"},
EMOTION_FORGIVE : {"name": localeInfo.EMOTION_FORGIVE, "command":"/forgive"},
EMOTION_ANGRY : {"name": localeInfo.EMOTION_ANGRY, "command":"/angry"},
EMOTION_ATTRACTIVE : {"name": localeInfo.EMOTION_ATTRACTIVE, "command":"/attractive"},
EMOTION_SAD : {"name": localeInfo.EMOTION_SAD, "command":"/sad"},
EMOTION_SHY : {"name": localeInfo.EMOTION_SHY, "command":"/shy"},
EMOTION_CHEERUP : {"name": localeInfo.EMOTION_CHEERUP, "command":"/cheerup"},
EMOTION_BANTER : {"name": localeInfo.EMOTION_BANTER, "command":"/banter"},
EMOTION_JOY : {"name": localeInfo.EMOTION_JOY, "command":"/joy"},
EMOTION_CHEERS_1 : {"name": localeInfo.EMOTION_CHEERS_1, "command":"/cheer1"},
EMOTION_CHEERS_2 : {"name": localeInfo.EMOTION_CHEERS_2, "command":"/cheer2"},
EMOTION_KISS : {"name": localeInfo.EMOTION_CLAP_KISS, "command":"/kiss"},
EMOTION_FRENCH_KISS : {"name": localeInfo.EMOTION_FRENCH_KISS, "command":"/french_kiss"},
EMOTION_SLAP : {"name": localeInfo.EMOTION_SLAP, "command":"/slap"},
}
elif EMOTION_VERSION == 1:
EMOTION_DICT = {
EMOTION_CLAP : {"name": localeInfo.EMOTION_CLAP, "command":"/clap"},
EMOTION_CHEERS_1 : {"name": localeInfo.EMOTION_CHEERS_1, "command":"/cheer1"},
EMOTION_CHEERS_2 : {"name": localeInfo.EMOTION_CHEERS_2, "command":"/cheer2"},
EMOTION_DANCE_1 : {"name": localeInfo.EMOTION_DANCE_1, "command":"/dance1"},
EMOTION_DANCE_2 : {"name": localeInfo.EMOTION_DANCE_2, "command":"/dance2"},
EMOTION_KISS : {"name": localeInfo.EMOTION_CLAP_KISS, "command":"/kiss"},
EMOTION_FRENCH_KISS : {"name": localeInfo.EMOTION_FRENCH_KISS, "command":"/french_kiss"},
EMOTION_SLAP : {"name": localeInfo.EMOTION_SLAP, "command":"/slap"},
}
else:
EMOTION_DICT = {
EMOTION_CLAP : {"name": localeInfo.EMOTION_CLAP, "command":"/clap"},
EMOTION_CHEERS_1 : {"name": localeInfo.EMOTION_CHEERS_1, "command":"/cheer1"},
EMOTION_CHEERS_2 : {"name": localeInfo.EMOTION_CHEERS_2, "command":"/cheer2"},
EMOTION_KISS : {"name": localeInfo.EMOTION_CLAP_KISS, "command":"/kiss"},
EMOTION_FRENCH_KISS : {"name": localeInfo.EMOTION_FRENCH_KISS, "command":"/french_kiss"},
EMOTION_SLAP : {"name": localeInfo.EMOTION_SLAP, "command":"/slap"},
}
_RebuildLocaleStrings()
localeInfo.RegisterReloadCallback(_RebuildLocaleStrings)
def __RegisterSharedEmotionAnis(mode, path):
chrmgr.SetPathName(path)
chrmgr.RegisterMotionMode(mode)
for key, val in list(ANI_DICT.items()):
chrmgr.RegisterMotionData(mode, key, val)
def RegisterEmotionAnis(path):
actionPath = path + "action/"
weddingPath = path + "wedding/"
__RegisterSharedEmotionAnis(chr.MOTION_MODE_GENERAL, actionPath)
__RegisterSharedEmotionAnis(chr.MOTION_MODE_WEDDING_DRESS, actionPath)
chrmgr.SetPathName(weddingPath)
chrmgr.RegisterMotionMode(chr.MOTION_MODE_WEDDING_DRESS)
chrmgr.RegisterMotionData(chr.MOTION_MODE_WEDDING_DRESS, chr.MOTION_WAIT, "wait.msa")
chrmgr.RegisterMotionData(chr.MOTION_MODE_WEDDING_DRESS, chr.MOTION_WALK, "walk.msa")
chrmgr.RegisterMotionData(chr.MOTION_MODE_WEDDING_DRESS, chr.MOTION_RUN, "walk.msa")
def RegisterEmotionIcons():
for key, val in list(ICON_DICT.items()):
player.RegisterEmotionIcon(key, val)
-38
View File
@@ -1,38 +0,0 @@
def GetExceptionString(excTitle):
import sys
(excType, excMsg, excTraceBack)=sys.exc_info()
excText=""
excText+=chr(10)
import traceback
traceLineList=traceback.extract_tb(excTraceBack)
for traceLine in traceLineList:
if traceLine[3]:
excText+="%s(line:%d) %s - %s" % (traceLine[0], traceLine[1], traceLine[2], traceLine[3])
else:
excText+="%s(line:%d) %s" % (traceLine[0], traceLine[1], traceLine[2])
excText+=chr(10)
excText+=chr(10)
excText+="%s - %s:%s" % (excTitle, excType, excMsg)
excText+=chr(10)
return excText
def Abort(excTitle):
import dbg
excText=GetExceptionString(excTitle)
dbg.TraceError(excText)
import app
app.Abort()
import sys
sys.exit()
return 0
-2232
View File
File diff suppressed because it is too large Load Diff
-15
View File
@@ -1,15 +0,0 @@
nv4_disp.dll 0006000e 000a1628
nv4_disp.dll 0006000e 000a1460
nv4_disp.dll 0006000e 000a14b7
nv4_disp.dll 0006000e.000a1620
nv4_disp.dll 0006000e.000a1628
nv4_disp.dll 0006000e.000a1a25
nv4_disp.dll 0006000e.000110ff
nv4_disp.dll 0006000e.000a1133
nv4_disp.dll 0006000e.000a11ab
nv4_disp.dll 0006000e.000a1629
nv4_disp.dll 0006000e.000a1820
nv4_disp.dll 0006000e.000a14b7
NVDD32.DLL 0004000d.00010b7e
ialmdd.dll 0004000d.000a0db6
ialmdd.dll 0004000d.00010cc0
File diff suppressed because it is too large Load Diff
-671
View File
@@ -1,671 +0,0 @@
import chr
import grp
import app
import net
import snd
import wndMgr
import event
import systemSetting
import localeInfo
import ui
import networkModule
import math
import snd
import musicInfo
import playerSettingModule
import uiScriptLocale
import uiToolTip
MAN = 0
WOMAN = 1
SHAPE0 = 0
SHAPE1 = 1
PAGE_COUNT = 2
SLOT_COUNT = 4
BASE_CHR_ID = 3
class CreateCharacterWindow(ui.Window):
SLOT_ROTATION = [135.0, 225.0, 315.0, 45.0]
CREATE_STAT_POINT = 0
STAT_CON = 0
STAT_INT = 1
STAT_STR = 2
STAT_DEX = 3
STAT_DESCRIPTION = {} # populated by _RebuildLocaleStrings()
START_STAT = ( ## CON INT STR DEX
[ 4, 3, 6, 3, ], ## Warrior
[ 3, 3, 4, 6, ], ## Assassin
[ 3, 5, 5, 3, ], ## Sura
[ 4, 6, 3, 3, ], ## Shaman
[ 4, 3, 6, 3, ], ## Warrior
[ 3, 3, 4, 6, ], ## Assassin
[ 3, 5, 5, 3, ], ## Sura
[ 4, 6, 3, 3, ], ## Shaman
)
DESCRIPTION_FILE_NAME = () # populated by _RebuildLocaleStrings()
@staticmethod
def _RebuildLocaleStrings():
CreateCharacterWindow.STAT_DESCRIPTION = {
CreateCharacterWindow.STAT_CON : localeInfo.STAT_TOOLTIP_CON,
CreateCharacterWindow.STAT_INT : localeInfo.STAT_TOOLTIP_INT,
CreateCharacterWindow.STAT_STR : localeInfo.STAT_TOOLTIP_STR,
CreateCharacterWindow.STAT_DEX : localeInfo.STAT_TOOLTIP_DEX,
}
CreateCharacterWindow.DESCRIPTION_FILE_NAME = (
uiScriptLocale.JOBDESC_WARRIOR_PATH,
uiScriptLocale.JOBDESC_ASSASSIN_PATH,
uiScriptLocale.JOBDESC_SURA_PATH,
uiScriptLocale.JOBDESC_SHAMAN_PATH,
)
class DescriptionBox(ui.Window):
def __init__(self):
ui.Window.__init__(self)
self.descIndex = 0
def __del__(self):
ui.Window.__del__(self)
def SetIndex(self, index):
self.descIndex = index
def OnRender(self):
event.RenderEventSet(self.descIndex)
class CharacterRenderer(ui.Window):
def OnRender(self):
grp.ClearDepthBuffer()
grp.SetGameRenderState()
grp.PushState()
grp.SetOmniLight()
screenWidth = wndMgr.GetScreenWidth()
screenHeight = wndMgr.GetScreenHeight()
newScreenWidth = float(screenWidth - 270)
newScreenHeight = float(screenHeight)
grp.SetViewport(270.0/screenWidth, 0.0, newScreenWidth/screenWidth, newScreenHeight/screenHeight)
app.SetCenterPosition(0.0, 0.0, 0.0)
app.SetCamera(1550.0, 15.0, 180.0, 95.0)
grp.SetPerspective(10.0, newScreenWidth/newScreenHeight, 1000.0, 3000.0)
(x, y) = app.GetCursorPosition()
grp.SetCursorPosition(x, y)
chr.Deform()
chr.Render()
grp.RestoreViewport()
grp.PopState()
grp.SetInterfaceRenderState()
def __init__(self, stream):
print("NEW CREATE WINDOW ----------------------------------------------------------------------------")
ui.Window.__init__(self)
net.SetPhaseWindow(net.PHASE_WINDOW_CREATE, self)
self.stream=stream
def __del__(self):
print("---------------------------------------------------------------------------- DELETE CREATE WINDOW")
net.SetPhaseWindow(net.PHASE_WINDOW_CREATE, 0)
ui.Window.__del__(self)
def Open(self):
print("OPEN CREATE WINDOW ----------------------------------------------------------------------------")
playerSettingModule.LoadGameData("INIT")
self.reservingRaceIndex = -1
self.reservingShapeIndex = -1
self.reservingStartTime = 0
self.stat = [0, 0, 0, 0]
self.gender = 0
self.slot = -1
self.shapeList = [
[0, 0, 0, 0],
[0, 0, 0, 0]]
self.descIndex = 0
try:
dlgBoard = ui.ScriptWindow()
pythonScriptLoader = ui.PythonScriptLoader()
if app.IsRTL():
pythonScriptLoader.LoadScriptFile(dlgBoard, uiScriptLocale.LOCALE_UISCRIPT_PATH + "createcharacterwindow.py")
else:
pythonScriptLoader.LoadScriptFile(dlgBoard, "UIScript/createcharacterwindow.py")
except:
import exception
exception.Abort("CreateCharacterWindow.Open.LoadObject")
try:
getChild = dlgBoard.GetChild
self.NameList = []
self.NameList.append(getChild("name_warrior"))
self.NameList.append(getChild("name_assassin"))
self.NameList.append(getChild("name_sura"))
self.NameList.append(getChild("name_shaman"))
self.GaugeList = []
self.GaugeList.append(getChild("hth_gauge"))
self.GaugeList.append(getChild("int_gauge"))
self.GaugeList.append(getChild("str_gauge"))
self.GaugeList.append(getChild("dex_gauge"))
self.btnCreate = getChild("create_button")
self.btnCancel = getChild("cancel_button")
self.btnPrev = getChild("prev_button")
self.btnNext = getChild("next_button")
self.btnLeft = getChild("left_button")
self.btnRight = getChild("right_button")
self.textBoard = getChild("text_board")
self.genderButtonList = []
self.genderButtonList.append(getChild("gender_button_01"))
self.genderButtonList.append(getChild("gender_button_02"))
self.shapeButtonList = []
self.shapeButtonList.append(getChild("shape_button_01"))
self.shapeButtonList.append(getChild("shape_button_02"))
self.editCharacterName = getChild("character_name_value")
self.statValue = []
self.statValue.append(getChild("hth_value"))
self.statValue.append(getChild("int_value"))
self.statValue.append(getChild("str_value"))
self.statValue.append(getChild("dex_value"))
getChild("hth_button").ShowToolTip = lambda arg=self.STAT_CON: self.OverInStatButton(arg)
getChild("hth_button").HideToolTip = lambda arg=self.STAT_CON: self.OverOutStatButton()
getChild("int_button").ShowToolTip = lambda arg=self.STAT_INT: self.OverInStatButton(arg)
getChild("int_button").HideToolTip = lambda arg=self.STAT_INT: self.OverOutStatButton()
getChild("str_button").ShowToolTip = lambda arg=self.STAT_STR: self.OverInStatButton(arg)
getChild("str_button").HideToolTip = lambda arg=self.STAT_STR: self.OverOutStatButton()
getChild("dex_button").ShowToolTip = lambda arg=self.STAT_DEX: self.OverInStatButton(arg)
getChild("dex_button").HideToolTip = lambda arg=self.STAT_DEX: self.OverOutStatButton()
getChild("hth_button").Hide()
getChild("int_button").Hide()
getChild("str_button").Hide()
getChild("dex_button").Hide()
self.backGround = getChild("BackGround")
except:
import exception
exception.Abort("CreateCharacterWindow.Open.BindObject")
self.btnCreate.SetEvent(ui.__mem_func__(self.CreateCharacter))
self.btnCancel.SetEvent(ui.__mem_func__(self.CancelCreate))
self.btnPrev.SetEvent(ui.__mem_func__(self.PrevDescriptionPage))
self.btnNext.SetEvent(ui.__mem_func__(self.NextDescriptionPage))
self.btnLeft.SetEvent(ui.__mem_func__(self.__DecreaseSlotIndex))
self.btnRight.SetEvent(ui.__mem_func__(self.__IncreaseSlotIndex))
self.genderButtonList[0].SetEvent(ui.__mem_func__(self.__SelectGender), MAN)
self.genderButtonList[1].SetEvent(ui.__mem_func__(self.__SelectGender), WOMAN)
self.shapeButtonList[0].SetEvent(ui.__mem_func__(self.__SelectShape), SHAPE0)
self.shapeButtonList[1].SetEvent(ui.__mem_func__(self.__SelectShape), SHAPE1)
self.editCharacterName.SetReturnEvent(ui.__mem_func__(self.CreateCharacter))
self.editCharacterName.SetEscapeEvent(ui.__mem_func__(self.CancelCreate))
self.dlgBoard = dlgBoard
self.curRotation = [] + self.SLOT_ROTATION
self.destRotation = [] + self.SLOT_ROTATION
self.curNameAlpha = [0.0, 0.0, 0.0, 0.0, 0.0]
self.destNameAlpha = [0.0, 0.0, 0.0, 0.0, 0.0]
self.curGauge = [0.0, 0.0, 0.0, 0.0]
self.destGauge = [0.0, 0.0, 0.0, 0.0]
self.descriptionBox = self.DescriptionBox()
self.descriptionBox.Show()
self.chrRenderer = self.CharacterRenderer()
self.chrRenderer.SetParent(self.backGround)
self.chrRenderer.Show()
self.toolTip = uiToolTip.ToolTip()
self.toolTip.ClearToolTip()
self.editCharacterName.SetText("")
self.EnableWindow()
self.__SelectSlot(0)
app.SetCamera(500.0, 10.0, 180.0, 95.0)
self.__MakeCharacter(0, 0, playerSettingModule.RACE_WARRIOR_M)
self.__MakeCharacter(0, 1, playerSettingModule.RACE_ASSASSIN_M)
self.__MakeCharacter(0, 2, playerSettingModule.RACE_SURA_M)
self.__MakeCharacter(0, 3, playerSettingModule.RACE_SHAMAN_M)
self.__MakeCharacter(1, 0, playerSettingModule.RACE_WARRIOR_W)
self.__MakeCharacter(1, 1, playerSettingModule.RACE_ASSASSIN_W)
self.__MakeCharacter(1, 2, playerSettingModule.RACE_SURA_W)
self.__MakeCharacter(1, 3, playerSettingModule.RACE_SHAMAN_W)
self.__SelectGender(app.GetRandom(MAN, WOMAN))
self.__SelectShape(0)
self.__SelectSlot(app.GetRandom(0, 3))
self.dlgBoard.Show()
self.Show()
if musicInfo.createMusic != "":
snd.SetMusicVolume(systemSetting.GetMusicVolume())
snd.FadeInMusic("BGM/"+musicInfo.createMusic)
app.ShowCursor()
def Close(self):
print("---------------------------------------------------------------------------- CLOSE CREATE WINDOW")
self.editCharacterName.Enable()
self.dlgBoard.ClearDictionary()
self.stream=0
self.shapeButtonList = []
self.genderButtonList = []
self.btnCreate = 0
self.btnCancel = 0
self.btnPrev = 0
self.btnNext = 0
self.btnLeft = 0
self.btnRight = 0
self.textBoard = 0
self.editCharacterName = 0
self.backGround = None
if musicInfo.createMusic != "":
snd.FadeOutMusic("BGM/"+musicInfo.createMusic)
for id in range(BASE_CHR_ID + SLOT_COUNT * PAGE_COUNT):
chr.DeleteInstance(id)
self.dlgBoard.Hide()
self.Hide()
app.HideCursor()
event.Destroy()
def EnableWindow(self):
self.reservingRaceIndex = -1
self.reservingShapeIndex = -1
self.btnCreate.Enable()
self.btnCancel.Enable()
self.btnPrev.Enable()
self.btnNext.Enable()
self.btnLeft.Enable()
self.btnRight.Enable()
self.editCharacterName.SetFocus()
self.editCharacterName.Enable()
for page in range(PAGE_COUNT):
for slot in range(SLOT_COUNT):
chr_id = self.__GetSlotChrID(page, slot)
chr.SelectInstance(chr_id)
chr.BlendLoopMotion(chr.MOTION_INTRO_WAIT, 0.1)
def DisableWindow(self):
self.btnCreate.Disable()
self.btnCancel.Disable()
self.btnPrev.Disable()
self.btnNext.Disable()
self.btnLeft.Disable()
self.btnRight.Disable()
self.editCharacterName.Disable()
self.btnCreate.SetUp()
## Manage Character
def __GetSlotChrID(self, page, slot):
return BASE_CHR_ID + page * SLOT_COUNT + slot
def __MakeCharacter(self, page, slot, race):
chr_id = self.__GetSlotChrID(page, slot)
chr.CreateInstance(chr_id)
chr.SelectInstance(chr_id)
chr.SetVirtualID(chr_id)
chr.SetRace(race)
chr.SetArmor(0)
chr.SetHair(0)
chr.Refresh()
chr.SetMotionMode(chr.MOTION_MODE_GENERAL)
chr.SetLoopMotion(chr.MOTION_INTRO_WAIT)
chr.SetRotation(0.0)
chr.Hide()
def __SelectGender(self, gender):
for button in self.genderButtonList:
button.SetUp()
self.genderButtonList[gender].Down()
self.gender = gender
if gender == MAN:
for i in range(SLOT_COUNT):
chr.SelectInstance(self.__GetSlotChrID(0, i))
chr.Show()
for i in range(SLOT_COUNT):
chr.SelectInstance(self.__GetSlotChrID(1, i))
chr.Hide()
else:
for i in range(SLOT_COUNT):
chr.SelectInstance(self.__GetSlotChrID(0, i))
chr.Hide()
for i in range(SLOT_COUNT):
chr.SelectInstance(self.__GetSlotChrID(1, i))
chr.Show()
def __SelectShape(self, shape):
self.shapeList[self.gender][self.slot] = shape
for button in self.shapeButtonList:
button.SetUp()
self.shapeButtonList[shape].Down()
chr_id = self.__GetSlotChrID(self.gender, self.slot)
chr.SelectInstance(chr_id)
chr.ChangeShape(shape)
chr.SetMotionMode(chr.MOTION_MODE_GENERAL)
chr.SetLoopMotion(chr.MOTION_INTRO_WAIT)
def GetSlotIndex(self):
return self.slot
def RefreshStat(self):
statSummary = self.stat[0] + self.stat[1] + self.stat[2] + self.stat[3]
self.destGauge = (
float(self.stat[0])/float(statSummary),
float(self.stat[1])/float(statSummary),
float(self.stat[2])/float(statSummary),
float(self.stat[3])/float(statSummary),
)
for i in range(4):
self.statValue[i].SetText(str(self.stat[i]))
def __SelectSlot(self, slot):
if slot < 0:
return
if slot >= SLOT_COUNT:
return
if self.slot == slot:
return
self.slot = slot
self.ResetStat()
for i in range(SLOT_COUNT):
self.destNameAlpha[i] = 0.0
self.destNameAlpha[slot] = 1.0
for i in range(SLOT_COUNT):
self.destRotation[(i+self.slot)%SLOT_COUNT] = self.SLOT_ROTATION[i]
if self.IsShow():
snd.PlaySound("sound/ui/click.wav")
event.ClearEventSet(self.descIndex)
self.descIndex = event.RegisterEventSet(self.DESCRIPTION_FILE_NAME[self.slot])
if app.IsRTL():
event.SetEventSetWidth(self.descIndex, 170)
chr_id = self.__GetSlotChrID(self.gender, slot)
if chr.HasInstance(chr_id):
chr.SelectInstance(chr_id)
self.__SelectShape(self.shapeList[self.gender][slot])
def CreateCharacter(self):
if -1 != self.reservingRaceIndex:
return
textName = self.editCharacterName.GetText()
if False == self.__CheckCreateCharacter(textName):
return
if musicInfo.selectMusic != "":
snd.FadeLimitOutMusic("BGM/"+musicInfo.selectMusic, systemSetting.GetMusicVolume()*0.05)
self.DisableWindow()
chr_id = self.__GetSlotChrID(self.gender, self.slot)
chr.SelectInstance(chr_id)
self.reservingRaceIndex = chr.GetRace()
self.reservingShapeIndex = self.shapeList[self.gender][self.slot]
self.reservingStartTime = app.GetTime()
for eachSlot in range(SLOT_COUNT):
sel_id = self.__GetSlotChrID(self.gender, eachSlot)
chr.SelectInstance(sel_id)
if eachSlot == self.slot:
chr.PushOnceMotion(chr.MOTION_INTRO_SELECTED)
else:
chr.PushOnceMotion(chr.MOTION_INTRO_NOT_SELECTED)
def CancelCreate(self):
self.stream.SetSelectCharacterPhase()
def __DecreaseSlotIndex(self):
slotIndex = (self.GetSlotIndex() - 1 + SLOT_COUNT) % SLOT_COUNT
self.__SelectSlot(slotIndex)
def __IncreaseSlotIndex(self):
slotIndex = (self.GetSlotIndex() + 1) % SLOT_COUNT
self.__SelectSlot(slotIndex)
def PrevDescriptionPage(self):
if True == event.IsWait(self.descIndex):
if event.GetVisibleStartLine(self.descIndex)-5 >= 0:
event.SetVisibleStartLine(self.descIndex, event.GetVisibleStartLine(self.descIndex)-5)
event.Skip(self.descIndex)
else:
event.Skip(self.descIndex)
def NextDescriptionPage(self):
if True == event.IsWait(self.descIndex):
event.SetVisibleStartLine(self.descIndex, event.GetVisibleStartLine(self.descIndex)+5)
event.Skip(self.descIndex)
else:
event.Skip(self.descIndex)
def __CheckCreateCharacter(self, name):
if len(name) == 0:
self.PopupMessage(localeInfo.CREATE_INPUT_NAME, self.EnableWindow)
return False
if name.find(localeInfo.CREATE_GM_NAME)!=-1:
self.PopupMessage(localeInfo.CREATE_ERROR_GM_NAME, self.EnableWindow)
return False
if net.IsInsultIn(name):
self.PopupMessage(localeInfo.CREATE_ERROR_INSULT_NAME, self.EnableWindow)
return False
return True
def ResetStat(self):
for i in range(4):
self.stat[i] = self.START_STAT[self.slot][i]
self.lastStatPoint = self.CREATE_STAT_POINT
self.RefreshStat()
## Event
def OnCreateSuccess(self):
self.stream.SetSelectCharacterPhase()
def OnCreateFailure(self, type):
if 1 == type:
self.PopupMessage(localeInfo.CREATE_EXIST_SAME_NAME, self.EnableWindow)
else:
self.PopupMessage(localeInfo.CREATE_FAILURE, self.EnableWindow)
def OnKeyDown(self, key):
if key == 2:
self.__SelectSlot(0)
if key == 3:
self.__SelectSlot(1)
if key == 4:
self.__SelectSlot(2)
if key == 5:
self.__SelectSlot(3)
if 203 == key:
self.__DecreaseSlotIndex()
if 205 == key:
self.__IncreaseSlotIndex()
if 59 == key:
self.__SelectGender(MAN_PAGE)
if 60 == key:
self.__SelectGender(WOMAN_PAGE)
return True
def OnUpdate(self):
chr.Update()
(xposEventSet, yposEventSet) = self.textBoard.GetGlobalPosition()
event.UpdateEventSet(self.descIndex, xposEventSet+7, -(yposEventSet+7))
self.descriptionBox.SetIndex(self.descIndex)
for i in range(4):
self.curNameAlpha[i] += (self.destNameAlpha[i] - self.curNameAlpha[i]) / 10.0
self.NameList[i].SetAlpha(self.curNameAlpha[i])
for i in range(4):
self.curGauge[i] += (self.destGauge[i] - self.curGauge[i]) / 10.0
if abs(self.curGauge[i] - self.destGauge[i]) < 0.005:
self.curGauge[i] = self.destGauge[i]
self.GaugeList[i].SetPercentage(self.curGauge[i], 1.0)
for page in range(PAGE_COUNT):
for i in range(SLOT_COUNT):
chr.SelectInstance(self.__GetSlotChrID(page, i))
distance = 50.0
rotRadian = self.curRotation[i] * (math.pi*2) / 360.0
x = distance*math.sin(rotRadian) + distance*math.cos(rotRadian)
y = distance*math.cos(rotRadian) - distance*math.sin(rotRadian)
chr.SetPixelPosition(int(x), int(y), 30)
if abs(self.destRotation[i] - self.curRotation[i]) < 1.0:
self.curRotation[i] = self.destRotation[i]
dir = app.GetRotatingDirection(self.destRotation[i], self.curRotation[i])
rot = app.GetDegreeDifference(self.destRotation[i], self.curRotation[i])
if app.DEGREE_DIRECTION_RIGHT == dir:
self.curRotation[i] += rot / 10.0
elif app.DEGREE_DIRECTION_LEFT == dir:
self.curRotation[i] -= rot / 10.0
self.curRotation[i] = (self.curRotation[i] + 360.0) % 360.0
###########################################################
if -1 != self.reservingRaceIndex:
if app.GetTime() - self.reservingStartTime >= 1.5:
chrSlot=self.stream.GetCharacterSlot()
textName = self.editCharacterName.GetText()
raceIndex = self.reservingRaceIndex
shapeIndex = self.reservingShapeIndex
startStat = self.START_STAT[self.reservingRaceIndex]
statCon = self.stat[0] - startStat[0]
statInt = self.stat[1] - startStat[1]
statStr = self.stat[2] - startStat[2]
statDex = self.stat[3] - startStat[3]
net.SendCreateCharacterPacket(chrSlot, textName, raceIndex, shapeIndex, statCon, statInt, statStr, statDex)
self.reservingRaceIndex = -1
###########################################################
def EmptyFunc(self):
pass
def PopupMessage(self, msg, func=0):
if not func:
func=self.EmptyFunc
self.stream.popupWindow.Close()
self.stream.popupWindow.Open(msg, func, localeInfo.UI_OK)
def OnPressExitKey(self):
self.CancelCreate()
return True
def OverInStatButton(self, stat):
if stat not in self.STAT_DESCRIPTION:
return
self.toolTip.ClearToolTip()
self.toolTip.AppendTextLine(self.STAT_DESCRIPTION[stat])
self.toolTip.Show()
def OverOutStatButton(self):
self.toolTip.Hide()
CreateCharacterWindow._RebuildLocaleStrings()
localeInfo.RegisterReloadCallback(CreateCharacterWindow._RebuildLocaleStrings)
if __name__ == "__main__":
import app
import wndMgr
import systemSetting
import mouseModule
import networkModule
app.SetMouseHandler(mouseModule.mouseController)
app.SetHairColorEnable(True)
wndMgr.SetMouseHandler(mouseModule.mouseController)
wndMgr.SetScreenSize(systemSetting.GetWidth(), systemSetting.GetHeight())
app.Create(localeInfo.APP_TITLE, systemSetting.GetWidth(), systemSetting.GetHeight(), 1)
mouseModule.mouseController.Create()
mainStream = networkModule.MainStream()
mainStream.Create()
test = CreateCharacterWindow(mainStream)
test.Open()
app.Loop()
-259
View File
@@ -1,259 +0,0 @@
import ui
import net
import wndMgr
import dbg
import app
import event
import _weakref
import localeInfo
import uiScriptLocale
class SelectEmpireWindow(ui.ScriptWindow):
EMPIRE_DESCRIPTION_TEXT_FILE_NAME = {
net.EMPIRE_A : uiScriptLocale.EMPIREDESC_A,
net.EMPIRE_B : uiScriptLocale.EMPIREDESC_B,
net.EMPIRE_C : uiScriptLocale.EMPIREDESC_C, }
class EmpireButton(ui.Window):
def __init__(self, owner, arg):
ui.Window.__init__(self)
self.owner = owner
self.arg = arg
def OnMouseOverIn(self):
self.owner.OnOverInEmpire(self.arg)
def OnMouseOverOut(self):
self.owner.OnOverOutEmpire(self.arg)
def OnMouseLeftButtonDown(self):
if self.owner.empireID != self.arg:
self.owner.OnSelectEmpire(self.arg)
class DescriptionBox(ui.Window):
def __init__(self):
ui.Window.__init__(self)
self.descIndex = 0
def __del__(self):
ui.Window.__del__(self)
def SetIndex(self, index):
self.descIndex = index
def OnRender(self):
event.RenderEventSet(self.descIndex)
def __init__(self, stream):
print("NEW EMPIRE WINDOW ----------------------------------------------------------------------------")
ui.ScriptWindow.__init__(self)
net.SetPhaseWindow(net.PHASE_WINDOW_EMPIRE, self)
self.stream=stream
self.empireID=app.GetRandom(1, 3)
self.descIndex=0
self.empireArea = {}
self.empireAreaFlag = {}
self.empireFlag = {}
self.empireAreaButton = {}
self.empireAreaCurAlpha = { net.EMPIRE_A:0.0, net.EMPIRE_B:0.0, net.EMPIRE_C:0.0 }
self.empireAreaDestAlpha = { net.EMPIRE_A:0.0, net.EMPIRE_B:0.0, net.EMPIRE_C:0.0 }
self.empireAreaFlagCurAlpha = { net.EMPIRE_A:0.0, net.EMPIRE_B:0.0, net.EMPIRE_C:0.0 }
self.empireAreaFlagDestAlpha = { net.EMPIRE_A:0.0, net.EMPIRE_B:0.0, net.EMPIRE_C:0.0 }
self.empireFlagCurAlpha = { net.EMPIRE_A:0.0, net.EMPIRE_B:0.0, net.EMPIRE_C:0.0 }
self.empireFlagDestAlpha = { net.EMPIRE_A:0.0, net.EMPIRE_B:0.0, net.EMPIRE_C:0.0 }
def __del__(self):
ui.ScriptWindow.__del__(self)
net.SetPhaseWindow(net.PHASE_WINDOW_EMPIRE, 0)
print("---------------------------------------------------------------------------- DELETE EMPIRE WINDOW")
def Close(self):
print("---------------------------------------------------------------------------- CLOSE EMPIRE WINDOW")
self.ClearDictionary()
self.leftButton = None
self.rightButton = None
self.selectButton = None
self.exitButton = None
self.textBoard = None
self.descriptionBox = None
self.empireArea = None
self.empireAreaButton = None
self.KillFocus()
self.Hide()
app.HideCursor()
event.Destroy()
def Open(self):
print("OPEN EMPIRE WINDOW ----------------------------------------------------------------------------")
self.SetSize(wndMgr.GetScreenWidth(), wndMgr.GetScreenHeight())
self.SetWindowName("SelectEmpireWindow")
self.Show()
if app.IsRTL():
selectPath = uiScriptLocale.LOCALE_UISCRIPT_PATH + "SelectEmpireWindow.py"
else:
selectPath = "UIScript/SelectEmpireWindow.py"
if not self.__LoadScript(selectPath):
dbg.TraceError("SelectCharacterWindow.Open - __LoadScript Error")
return
self.OnSelectEmpire(self.empireID)
self.__CreateButtons()
self.__CreateDescriptionBox()
app.ShowCursor()
def __CreateButtons(self):
for key, img in list(self.empireArea.items()):
img.SetAlpha(0.0)
(x, y) = img.GetGlobalPosition()
btn = self.EmpireButton(_weakref.proxy(self), key)
btn.SetParent(self)
btn.SetPosition(x, y)
btn.SetSize(img.GetWidth(), img.GetHeight())
btn.Show()
self.empireAreaButton[key] = btn
def __CreateDescriptionBox(self):
self.descriptionBox = self.DescriptionBox()
self.descriptionBox.Show()
def OnOverInEmpire(self, arg):
self.empireAreaDestAlpha[arg] = 1.0
def OnOverOutEmpire(self, arg):
if arg != self.empireID:
self.empireAreaDestAlpha[arg] = 0.0
def OnSelectEmpire(self, arg):
for key in list(self.empireArea.keys()):
self.empireAreaDestAlpha[key] = 0.0
self.empireAreaFlagDestAlpha[key] = 0.0
self.empireFlagDestAlpha[key] = 0.0
self.empireAreaDestAlpha[arg] = 1.0
self.empireAreaFlagDestAlpha[arg] = 1.0
self.empireFlagDestAlpha[arg] = 1.0
self.empireID = arg
event.ClearEventSet(self.descIndex)
if arg in self.EMPIRE_DESCRIPTION_TEXT_FILE_NAME:
self.descIndex = event.RegisterEventSet(self.EMPIRE_DESCRIPTION_TEXT_FILE_NAME[arg])
if app.IsRTL():
event.SetEventSetWidth(self.descIndex, 170)
else:
event.SetRestrictedCount(self.descIndex, 35)
def PrevDescriptionPage(self):
if True == event.IsWait(self.descIndex):
if event.GetVisibleStartLine(self.descIndex)-5 >= 0:
event.SetVisibleStartLine(self.descIndex, event.GetVisibleStartLine(self.descIndex)-5)
event.Skip(self.descIndex)
else:
event.Skip(self.descIndex)
def NextDescriptionPage(self):
if True == event.IsWait(self.descIndex):
event.SetVisibleStartLine(self.descIndex, event.GetVisibleStartLine(self.descIndex)+5)
event.Skip(self.descIndex)
else:
event.Skip(self.descIndex)
def __LoadScript(self, fileName):
try:
pyScrLoader = ui.PythonScriptLoader()
pyScrLoader.LoadScriptFile(self, fileName)
except:
import exception
exception.Abort("SelectEmpireWindow.__LoadScript.LoadObject")
try:
GetObject=self.GetChild
self.leftButton = GetObject("left_button")
self.rightButton = GetObject("right_button")
self.selectButton = GetObject("select_button")
self.exitButton = GetObject("exit_button")
self.textBoard = GetObject("text_board")
self.empireArea[net.EMPIRE_A] = GetObject("EmpireArea_A")
self.empireArea[net.EMPIRE_B] = GetObject("EmpireArea_B")
self.empireArea[net.EMPIRE_C] = GetObject("EmpireArea_C")
self.empireAreaFlag[net.EMPIRE_A] = GetObject("EmpireAreaFlag_A")
self.empireAreaFlag[net.EMPIRE_B] = GetObject("EmpireAreaFlag_B")
self.empireAreaFlag[net.EMPIRE_C] = GetObject("EmpireAreaFlag_C")
self.empireFlag[net.EMPIRE_A] = GetObject("EmpireFlag_A")
self.empireFlag[net.EMPIRE_B] = GetObject("EmpireFlag_B")
self.empireFlag[net.EMPIRE_C] = GetObject("EmpireFlag_C")
GetObject("prev_text_button").SetEvent(ui.__mem_func__(self.PrevDescriptionPage))
GetObject("next_text_button").SetEvent(ui.__mem_func__(self.NextDescriptionPage))
except:
import exception
exception.Abort("SelectEmpireWindow.__LoadScript.BindObject")
self.selectButton.SetEvent(ui.__mem_func__(self.ClickSelectButton))
self.exitButton.SetEvent(ui.__mem_func__(self.ClickExitButton))
self.leftButton.SetEvent(ui.__mem_func__(self.ClickLeftButton))
self.rightButton.SetEvent(ui.__mem_func__(self.ClickRightButton))
for flag in list(self.empireAreaFlag.values()):
flag.SetAlpha(0.0)
for flag in list(self.empireFlag.values()):
flag.SetAlpha(0.0)
return 1
def ClickLeftButton(self):
self.empireID-=1
if self.empireID<1:
self.empireID=3
self.OnSelectEmpire(self.empireID)
def ClickRightButton(self):
self.empireID+=1
if self.empireID>3:
self.empireID=1
self.OnSelectEmpire(self.empireID)
def ClickSelectButton(self):
net.SendSelectEmpirePacket(self.empireID)
self.stream.SetSelectCharacterPhase()
def ClickExitButton(self):
self.stream.SetLoginPhase()
def OnUpdate(self):
(xposEventSet, yposEventSet) = self.textBoard.GetGlobalPosition()
event.UpdateEventSet(self.descIndex, xposEventSet+7, -(yposEventSet+7))
self.descriptionBox.SetIndex(self.descIndex)
self.__UpdateAlpha(self.empireArea, self.empireAreaCurAlpha, self.empireAreaDestAlpha)
self.__UpdateAlpha(self.empireAreaFlag, self.empireAreaFlagCurAlpha, self.empireAreaFlagDestAlpha)
self.__UpdateAlpha(self.empireFlag, self.empireFlagCurAlpha, self.empireFlagDestAlpha)
def __UpdateAlpha(self, dict, curAlphaDict, destAlphaDict):
for key, img in list(dict.items()):
curAlpha = curAlphaDict[key]
destAlpha = destAlphaDict[key]
if abs(destAlpha - curAlpha) / 10 > 0.0001:
curAlpha += (destAlpha - curAlpha) / 7
else:
curAlpha = destAlpha
curAlphaDict[key] = curAlpha
img.SetAlpha(curAlpha)
def OnPressEscapeKey(self):
self.ClickExitButton()
return True
class ReselectEmpireWindow(SelectEmpireWindow):
def ClickSelectButton(self):
net.SendSelectEmpirePacket(self.empireID)
self.stream.SetCreateCharacterPhase()
def ClickExitButton(self):
self.stream.SetSelectCharacterPhase()
-358
View File
@@ -1,358 +0,0 @@
import ui
import uiScriptLocale
import net
import app
import dbg
import player
import background
import wndMgr
import localeInfo
import chrmgr
import colorInfo
import constInfo
import playerSettingModule
import stringCommander
import emotion
####################################
# 빠른 실행을 위한 모듈 로딩 분담
####################################
import uiRefine
import uiToolTip
import uiAttachMetin
import uiPickMoney
import uiChat
import uiMessenger
import uiHelp
import uiWhisper
import uiPointReset
import uiShop
import uiExchange
import uiSystem
import uiOption
import uiRestart
####################################
class LoadingWindow(ui.ScriptWindow):
def __init__(self, stream):
print("NEW LOADING WINDOW -------------------------------------------------------------------------------")
ui.Window.__init__(self)
net.SetPhaseWindow(net.PHASE_WINDOW_LOAD, self)
self.stream=stream
self.loadingImage=0
self.loadingGage=0
self.errMsg=0
self.update=0
self.playerX=0
self.playerY=0
self.loadStepList=[]
def __del__(self):
print("---------------------------------------------------------------------------- DELETE LOADING WINDOW")
net.SetPhaseWindow(net.PHASE_WINDOW_LOAD, 0)
ui.Window.__del__(self)
def Open(self):
print("OPEN LOADING WINDOW -------------------------------------------------------------------------------")
#app.HideCursor()
try:
pyScrLoader = ui.PythonScriptLoader()
pyScrLoader.LoadScriptFile(self, "UIScript/LoadingWindow.py")
except:
import exception
exception.Abort("LodingWindow.Open - LoadScriptFile Error")
try:
self.loadingImage=self.GetChild("BackGround")
self.errMsg=self.GetChild("ErrorMessage")
self.loadingGage=self.GetChild("FullGage")
except:
import exception
exception.Abort("LodingWindow.Open - LoadScriptFile Error")
self.errMsg.Hide()
# Loading merged together
imgFileNameDict = {
# Base
0 : "d:/ymir work/uiloading/base/background_loading_warrior.sub",
1 : "d:/ymir work/uiloading/base/background_loading_shaman.sub",
2 : "d:/ymir work/uiloading/base/background_loading_sura.sub",
3 : "d:/ymir work/uiloading/base/background_loading_assassin.sub",
4 : "d:/ymir work/uiloading/base/background_loading_assassin2.sub",
5 : "d:/ymir work/uiloading/base/background_loading_assassin3.sub",
6 : "d:/ymir work/uiloading/base/background_loading_sura2.sub",
7 : "d:/ymir work/uiloading/base/background_loading_assassin3.sub",
# Grotto
8 : "d:/ymir work/uiloading/grotto/background_loading_samahi1.sub",
9 : "d:/ymir work/uiloading/grotto/background_loading_warrior5.sub",
10 : "d:/ymir work/uiloading/grotto/background_loading_warriorghist1.sub",
# Catacomb
11 : "d:/ymir work/uiloading/catacomb/loading0.sub",
12 : "d:/ymir work/uiloading/catacomb/loading1.sub",
13 : "d:/ymir work/uiloading/catacomb/loading2.sub",
14 : "d:/ymir work/uiloading/catacomb/loading3.sub",
# Dark Dragons
15 : "d:/ymir work/uiloading/dark_dragons/loading0.sub",
16 : "d:/ymir work/uiloading/dark_dragons/loading1.sub",
17 : "d:/ymir work/uiloading/dark_dragons/loading2.sub",
18 : "d:/ymir work/uiloading/dark_dragons/loading3.sub",
# Purgatory
19 : "d:/ymir work/uiloading/purgatory/loading0.sub",
20 : "d:/ymir work/uiloading/purgatory/loading1.sub",
21 : "d:/ymir work/uiloading/purgatory/loading2.sub",
22 : "d:/ymir work/uiloading/purgatory/loading3.sub",
}
try:
imgFileName = imgFileNameDict[app.GetRandom(0, len(imgFileNameDict) - 1)]
self.loadingImage.LoadImage(imgFileName)
except:
print(("LoadingWindow.Open.LoadImage - %s File Load Error" % (imgFileName)))
self.loadingImage.Hide()
width = float(wndMgr.GetScreenWidth()) / float(self.loadingImage.GetWidth())
height = float(wndMgr.GetScreenHeight()) / float(self.loadingImage.GetHeight())
self.loadingImage.SetScale(width, height)
self.loadingGage.SetPercentage(2, 100)
self.Show()
chrSlot=self.stream.GetCharacterSlot()
net.SendSelectCharacterPacket(chrSlot)
app.SetFrameSkip(0)
def Close(self):
print("---------------------------------------------------------------------------- CLOSE LOADING WINDOW")
app.SetFrameSkip(1)
self.loadStepList=[]
self.loadingImage=0
self.loadingGage=0
self.errMsg=0
self.ClearDictionary()
self.Hide()
def OnPressEscapeKey(self):
app.SetFrameSkip(1)
self.stream.SetLoginPhase()
return True
def __SetNext(self, next):
if next:
self.update=ui.__mem_func__(next)
else:
self.update=0
def __SetProgress(self, p):
if self.loadingGage:
self.loadingGage.SetPercentage(2+98*p/100, 100)
def DEBUG_LoadData(self, playerX, playerY):
self.playerX=playerX
self.playerY=playerY
self.__RegisterSkill() ## 로딩 중간에 실행 하면 문제 발생
self.__RegisterTitleName()
self.__RegisterColor()
self.__InitData()
self.__LoadMap()
self.__LoadSound()
self.__LoadEffect()
self.__LoadWarrior()
self.__LoadAssassin()
self.__LoadSura()
self.__LoadShaman()
self.__LoadSkill()
self.__LoadEnemy()
self.__LoadNPC()
self.__StartGame()
def LoadData(self, playerX, playerY):
self.playerX=playerX
self.playerY=playerY
self.__RegisterDungeonMapName()
self.__RegisterSkill() ## 로딩 중간에 실행 하면 문제 발생
self.__RegisterTitleName()
self.__RegisterColor()
self.__RegisterEmotionIcon()
self.loadStepList=[
(0, ui.__mem_func__(self.__InitData)),
(10, ui.__mem_func__(self.__LoadMap)),
(30, ui.__mem_func__(self.__LoadSound)),
(40, ui.__mem_func__(self.__LoadEffect)),
(50, ui.__mem_func__(self.__LoadWarrior)),
(60, ui.__mem_func__(self.__LoadAssassin)),
(70, ui.__mem_func__(self.__LoadSura)),
(80, ui.__mem_func__(self.__LoadShaman)),
(90, ui.__mem_func__(self.__LoadSkill)),
(93, ui.__mem_func__(self.__LoadEnemy)),
(97, ui.__mem_func__(self.__LoadNPC)),
# GUILD_BUILDING
(98, ui.__mem_func__(self.__LoadGuildBuilding)),
# END_OF_GUILD_BUILDING
(100, ui.__mem_func__(self.__StartGame)),
]
self.__SetProgress(0)
#self.__SetNext(self.__LoadMap)
def OnUpdate(self):
if len(self.loadStepList)>0:
(progress, runFunc)=self.loadStepList[0]
try:
runFunc()
except:
self.errMsg.Show()
self.loadStepList=[]
## 이곳에서 syserr.txt 를 보낸다.
import dbg
dbg.TraceError(" !!! Failed to load game data : STEP [%d]" % (progress))
#import shutil
#import os
#shutil.copyfile("syserr.txt", "errorlog.txt")
#os.system("errorlog.exe")
app.Exit()
return
self.loadStepList.pop(0)
self.__SetProgress(progress)
def __InitData(self):
playerSettingModule.LoadGameData("INIT")
def __RegisterDungeonMapName(self):
background.RegisterDungeonMapName("metin2_map_spiderdungeon")
background.RegisterDungeonMapName("metin2_map_monkeydungeon")
background.RegisterDungeonMapName("metin2_map_monkeydungeon_02")
background.RegisterDungeonMapName("metin2_map_monkeydungeon_03")
background.RegisterDungeonMapName("metin2_map_deviltower1")
def __RegisterSkill(self):
race = net.GetMainActorRace()
group = net.GetMainActorSkillGroup()
empire = net.GetMainActorEmpire()
playerSettingModule.RegisterSkill(race, group, empire)
def __RegisterTitleName(self):
for i in range(len(localeInfo.TITLE_NAME_LIST)):
chrmgr.RegisterTitleName(i, localeInfo.TITLE_NAME_LIST[i])
def __RegisterColor(self):
## Name
NAME_COLOR_DICT = {
chrmgr.NAMECOLOR_PC : colorInfo.CHR_NAME_RGB_PC,
chrmgr.NAMECOLOR_NPC : colorInfo.CHR_NAME_RGB_NPC,
chrmgr.NAMECOLOR_MOB : colorInfo.CHR_NAME_RGB_MOB,
chrmgr.NAMECOLOR_PVP : colorInfo.CHR_NAME_RGB_PVP,
chrmgr.NAMECOLOR_PK : colorInfo.CHR_NAME_RGB_PK,
chrmgr.NAMECOLOR_PARTY : colorInfo.CHR_NAME_RGB_PARTY,
chrmgr.NAMECOLOR_WARP : colorInfo.CHR_NAME_RGB_WARP,
chrmgr.NAMECOLOR_WAYPOINT : colorInfo.CHR_NAME_RGB_WAYPOINT,
chrmgr.NAMECOLOR_EMPIRE_MOB : colorInfo.CHR_NAME_RGB_EMPIRE_MOB,
chrmgr.NAMECOLOR_EMPIRE_NPC : colorInfo.CHR_NAME_RGB_EMPIRE_NPC,
chrmgr.NAMECOLOR_EMPIRE_PC+1 : colorInfo.CHR_NAME_RGB_EMPIRE_PC_A,
chrmgr.NAMECOLOR_EMPIRE_PC+2 : colorInfo.CHR_NAME_RGB_EMPIRE_PC_B,
chrmgr.NAMECOLOR_EMPIRE_PC+3 : colorInfo.CHR_NAME_RGB_EMPIRE_PC_C,
}
for name, rgb in list(NAME_COLOR_DICT.items()):
chrmgr.RegisterNameColor(name, rgb[0], rgb[1], rgb[2])
## Title
TITLE_COLOR_DICT = ( colorInfo.TITLE_RGB_GOOD_4,
colorInfo.TITLE_RGB_GOOD_3,
colorInfo.TITLE_RGB_GOOD_2,
colorInfo.TITLE_RGB_GOOD_1,
colorInfo.TITLE_RGB_NORMAL,
colorInfo.TITLE_RGB_EVIL_1,
colorInfo.TITLE_RGB_EVIL_2,
colorInfo.TITLE_RGB_EVIL_3,
colorInfo.TITLE_RGB_EVIL_4, )
count = 0
for rgb in TITLE_COLOR_DICT:
chrmgr.RegisterTitleColor(count, rgb[0], rgb[1], rgb[2])
count += 1
def __RegisterEmotionIcon(self):
emotion.RegisterEmotionIcons()
def __LoadMap(self):
net.Warp(self.playerX, self.playerY)
def __LoadSound(self):
playerSettingModule.LoadGameData("SOUND")
def __LoadEffect(self):
playerSettingModule.LoadGameData("EFFECT")
def __LoadWarrior(self):
playerSettingModule.LoadGameData("WARRIOR")
def __LoadAssassin(self):
playerSettingModule.LoadGameData("ASSASSIN")
def __LoadSura(self):
playerSettingModule.LoadGameData("SURA")
def __LoadShaman(self):
playerSettingModule.LoadGameData("SHAMAN")
def __LoadSkill(self):
playerSettingModule.LoadGameData("SKILL")
def __LoadEnemy(self):
playerSettingModule.LoadGameData("ENEMY")
def __LoadNPC(self):
playerSettingModule.LoadGameData("NPC")
# GUILD_BUILDING
def __LoadGuildBuilding(self):
playerSettingModule.LoadGuildBuildingList(localeInfo.GUILD_BUILDING_LIST_TXT)
# END_OF_GUILD_BUILDING
def __StartGame(self):
background.SetViewDistanceSet(background.DISTANCE0, 25600)
"""
background.SetViewDistanceSet(background.DISTANCE1, 19200)
background.SetViewDistanceSet(background.DISTANCE2, 12800)
background.SetViewDistanceSet(background.DISTANCE3, 9600)
background.SetViewDistanceSet(background.DISTANCE4, 6400)
"""
background.SelectViewDistanceNum(background.DISTANCE0)
app.SetGlobalCenterPosition(self.playerX, self.playerY)
net.StartGame()
def _ReloadTitleNames():
for i in range(len(localeInfo.TITLE_NAME_LIST)):
chrmgr.RegisterTitleName(i, localeInfo.TITLE_NAME_LIST[i])
chrmgr.RefreshAllPCTextTail()
localeInfo.RegisterReloadCallback(_ReloadTitleNames)
File diff suppressed because it is too large Load Diff
-781
View File
@@ -1,781 +0,0 @@
import chr
import grp
import app
import math
import wndMgr
import snd
import net
import systemSetting
import localeInfo
import chr
import ui
import uiScriptLocale
import networkModule
import musicInfo
import playerSettingModule
####################################
# 빠른 실행을 위한 모듈 로딩 분담
####################################
import uiCommon
import uiMapNameShower
import uiAffectShower
import uiPlayerGauge
import uiCharacter
import uiTarget
import consoleModule
# interface module이 문제야...
import interfaceModule
import uiTaskBar
import uiInventory
###################################
LEAVE_BUTTON_FOR_POTAL = False
NOT_NEED_DELETE_CODE = False
ENABLE_ENGNUM_DELETE_CODE = False
###################################
class SelectCharacterWindow(ui.Window):
# SLOT4
#SLOT_ROTATION = ( 140.0, 260.0, 20.0 )
#SLOT_COUNT = 3
SLOT_ROTATION = [135.0, 225.0, 315.0, 45.0]
SLOT_COUNT = 4
CHARACTER_TYPE_COUNT = 4
EMPIRE_NAME = {} # populated by _RebuildLocaleStrings()
@staticmethod
def _RebuildLocaleStrings():
SelectCharacterWindow.EMPIRE_NAME = {
net.EMPIRE_A : localeInfo.EMPIRE_A,
net.EMPIRE_B : localeInfo.EMPIRE_B,
net.EMPIRE_C : localeInfo.EMPIRE_C,
}
class CharacterRenderer(ui.Window):
def OnRender(self):
grp.ClearDepthBuffer()
grp.SetGameRenderState()
grp.PushState()
grp.SetOmniLight()
screenWidth = wndMgr.GetScreenWidth()
screenHeight = wndMgr.GetScreenHeight()
newScreenWidth = float(screenWidth - 270)
newScreenHeight = float(screenHeight)
grp.SetViewport(270.0/screenWidth, 0.0, newScreenWidth/screenWidth, newScreenHeight/screenHeight)
app.SetCenterPosition(0.0, 0.0, 0.0)
app.SetCamera(1550.0, 15.0, 180.0, 95.0)
grp.SetPerspective(10.0, newScreenWidth/newScreenHeight, 1000.0, 3000.0)
(x, y) = app.GetCursorPosition()
grp.SetCursorPosition(x, y)
chr.Deform()
chr.Render()
grp.RestoreViewport()
grp.PopState()
grp.SetInterfaceRenderState()
def __init__(self, stream):
ui.Window.__init__(self)
net.SetPhaseWindow(net.PHASE_WINDOW_SELECT, self)
self.stream=stream
self.slot = self.stream.GetCharacterSlot()
self.openLoadingFlag = False
self.startIndex = -1
self.startReservingTime = 0
self.flagDict = {}
self.curRotation = []
self.destRotation = []
for rot in self.SLOT_ROTATION:
self.curRotation.append(rot)
self.destRotation.append(rot)
self.curNameAlpha = []
self.destNameAlpha = []
for i in range(self.CHARACTER_TYPE_COUNT):
self.curNameAlpha.append(0.0)
self.destNameAlpha.append(0.0)
self.curGauge = [0.0, 0.0, 0.0, 0.0]
self.destGauge = [0.0, 0.0, 0.0, 0.0]
self.dlgBoard = 0
self.changeNameFlag = False
self.nameInputBoard = None
self.sendedChangeNamePacket = False
self.startIndex = -1
self.isLoad = 0
def __del__(self):
ui.Window.__del__(self)
net.SetPhaseWindow(net.PHASE_WINDOW_SELECT, 0)
def Open(self):
if app.IsRTL():
selectPath = uiScriptLocale.LOCALE_UISCRIPT_PATH + "selectcharacterwindow.py"
else:
selectPath = "UIScript/selectcharacterwindow.py"
if not self.__LoadBoardDialog(selectPath):
import dbg
dbg.TraceError("SelectCharacterWindow.Open - __LoadScript Error")
return
if not self.__LoadQuestionDialog("uiscript/questiondialog.py"):
return
playerSettingModule.LoadGameData("INIT")
self.InitCharacterBoard()
self.btnStart.Enable()
self.btnCreate.Enable()
self.btnDelete.Enable()
self.btnExit.Enable()
self.btnLeft.Enable()
self.btnRight.Enable()
self.dlgBoard.Show()
self.SetWindowName("SelectCharacterWindow")
self.Show()
if self.slot>=0:
self.SelectSlot(self.slot)
if musicInfo.selectMusic != "":
snd.SetMusicVolume(systemSetting.GetMusicVolume())
snd.FadeInMusic("BGM/"+musicInfo.selectMusic)
app.SetCenterPosition(0.0, 0.0, 0.0)
app.SetCamera(1550.0, 15.0, 180.0, 95.0)
self.isLoad=1
self.Refresh()
if self.stream.isAutoSelect:
chrSlot=self.stream.GetCharacterSlot()
self.SelectSlot(chrSlot)
self.StartGame()
self.HideAllFlag()
self.SetEmpire(net.GetEmpireID())
app.ShowCursor()
def Close(self):
if musicInfo.selectMusic != "":
snd.FadeOutMusic("BGM/"+musicInfo.selectMusic)
self.stream.popupWindow.Close()
if self.dlgBoard:
self.dlgBoard.ClearDictionary()
self.empireName = None
self.flagDict = {}
self.dlgBoard = None
self.btnStart = None
self.btnCreate = None
self.btnDelete = None
self.btnExit = None
self.btnLeft = None
self.btnRight = None
self.backGround = None
self.dlgQuestion.ClearDictionary()
self.dlgQuestion = None
self.dlgQuestionText = None
self.dlgQuestionAcceptButton = None
self.dlgQuestionCancelButton = None
self.privateInputBoard = None
self.nameInputBoard = None
chr.DeleteInstance(0)
chr.DeleteInstance(1)
chr.DeleteInstance(2)
chr.DeleteInstance(3)
self.Hide()
self.KillFocus()
app.HideCursor()
def SetEmpire(self, id):
self.empireName.SetText(self.EMPIRE_NAME.get(id, ""))
if id in self.flagDict:
self.flagDict[id].Show()
def HideAllFlag(self):
for flag in list(self.flagDict.values()):
flag.Hide()
def Refresh(self):
if not self.isLoad:
return
# SLOT4
indexArray = (3, 2, 1, 0)
for index in indexArray:
id=net.GetAccountCharacterSlotDataInteger(index, net.ACCOUNT_CHARACTER_SLOT_ID)
race=net.GetAccountCharacterSlotDataInteger(index, net.ACCOUNT_CHARACTER_SLOT_RACE)
form=net.GetAccountCharacterSlotDataInteger(index, net.ACCOUNT_CHARACTER_SLOT_FORM)
name=net.GetAccountCharacterSlotDataString(index, net.ACCOUNT_CHARACTER_SLOT_NAME)
hair=net.GetAccountCharacterSlotDataInteger(index, net.ACCOUNT_CHARACTER_SLOT_HAIR)
if id:
self.MakeCharacter(index, id, name, race, form, hair)
self.SelectSlot(index)
self.SelectSlot(self.slot)
def GetCharacterSlotID(self, slotIndex):
return net.GetAccountCharacterSlotDataInteger(slotIndex, net.ACCOUNT_CHARACTER_SLOT_ID)
def __LoadQuestionDialog(self, fileName):
self.dlgQuestion = ui.ScriptWindow()
try:
pyScrLoader = ui.PythonScriptLoader()
pyScrLoader.LoadScriptFile(self.dlgQuestion, fileName)
except:
import exception
exception.Abort("SelectCharacterWindow.LoadQuestionDialog.LoadScript")
try:
GetObject=self.dlgQuestion.GetChild
self.dlgQuestionText=GetObject("message")
self.dlgQuestionAcceptButton=GetObject("accept")
self.dlgQuestionCancelButton=GetObject("cancel")
except:
import exception
exception.Abort("SelectCharacterWindow.LoadQuestionDialog.BindObject")
self.dlgQuestionText.SetText(localeInfo.SELECT_DO_YOU_DELETE_REALLY)
self.dlgQuestionAcceptButton.SetEvent(ui.__mem_func__(self.RequestDeleteCharacter))
self.dlgQuestionCancelButton.SetEvent(ui.__mem_func__(self.dlgQuestion.Hide))
return 1
def __LoadBoardDialog(self, fileName):
self.dlgBoard = ui.ScriptWindow()
try:
pyScrLoader = ui.PythonScriptLoader()
pyScrLoader.LoadScriptFile(self.dlgBoard, fileName)
except:
import exception
exception.Abort("SelectCharacterWindow.LoadBoardDialog.LoadScript")
try:
GetObject=self.dlgBoard.GetChild
self.btnStart = GetObject("start_button")
self.btnCreate = GetObject("create_button")
self.btnDelete = GetObject("delete_button")
self.btnExit = GetObject("exit_button")
self.CharacterName = GetObject("character_name_value")
self.CharacterLevel = GetObject("character_level_value")
self.PlayTime = GetObject("character_play_time_value")
self.CharacterHTH = GetObject("character_hth_value")
self.CharacterINT = GetObject("character_int_value")
self.CharacterSTR = GetObject("character_str_value")
self.CharacterDEX = GetObject("character_dex_value")
self.GuildName = GetObject("GuildName")
self.NameList = []
self.NameList.append(GetObject("name_warrior"))
self.NameList.append(GetObject("name_assassin"))
self.NameList.append(GetObject("name_sura"))
self.NameList.append(GetObject("name_shaman"))
self.GaugeList = []
self.GaugeList.append(GetObject("gauge_hth"))
self.GaugeList.append(GetObject("gauge_int"))
self.GaugeList.append(GetObject("gauge_str"))
self.GaugeList.append(GetObject("gauge_dex"))
self.btnLeft = GetObject("left_button")
self.btnRight = GetObject("right_button")
self.empireName = GetObject("EmpireName")
self.flagDict[net.EMPIRE_A] = GetObject("EmpireFlag_A")
self.flagDict[net.EMPIRE_B] = GetObject("EmpireFlag_B")
self.flagDict[net.EMPIRE_C] = GetObject("EmpireFlag_C")
self.backGround = GetObject("BackGround")
except:
import exception
exception.Abort("SelectCharacterWindow.LoadBoardDialog.BindObject")
for name in self.NameList:
name.SetAlpha(0.0)
self.btnStart.SetEvent(ui.__mem_func__(self.StartGame))
self.btnCreate.SetEvent(ui.__mem_func__(self.CreateCharacter))
self.btnExit.SetEvent(ui.__mem_func__(self.ExitSelect))
if NOT_NEED_DELETE_CODE:
self.btnDelete.SetEvent(ui.__mem_func__(self.PopupDeleteQuestion))
else:
self.btnDelete.SetEvent(ui.__mem_func__(self.InputPrivateCode))
self.btnLeft.SetEvent(ui.__mem_func__(self.DecreaseSlotIndex))
self.btnRight.SetEvent(ui.__mem_func__(self.IncreaseSlotIndex))
self.chrRenderer = self.CharacterRenderer()
self.chrRenderer.SetParent(self.backGround)
self.chrRenderer.Show()
return 1
def SameLoginDisconnect(self):
self.stream.popupWindow.Close()
self.stream.popupWindow.Open(localeInfo.LOGIN_FAILURE_SAMELOGIN, self.ExitSelect, localeInfo.UI_OK)
#self.stream.popupWindow.Open(localeInfo.LOGIN_FAILURE_ALREAY, app.Exit, localeInfo.UI_OK)
def MakeCharacter(self, index, id, name, race, form, hair):
if 0 == id:
return
chr.CreateInstance(index)
chr.SelectInstance(index)
chr.SetVirtualID(index)
chr.SetNameString(name)
chr.SetRace(race)
chr.SetArmor(form)
chr.SetHair(hair)
chr.Refresh()
chr.SetMotionMode(chr.MOTION_MODE_GENERAL)
chr.SetLoopMotion(chr.MOTION_INTRO_WAIT)
chr.SetRotation(0.0)
## Manage Character
def StartGame(self):
if self.sendedChangeNamePacket:
return
if self.changeNameFlag:
self.OpenChangeNameDialog()
return
if -1 != self.startIndex:
return
if musicInfo.selectMusic != "":
snd.FadeLimitOutMusic("BGM/"+musicInfo.selectMusic, systemSetting.GetMusicVolume()*0.05)
self.btnStart.SetUp()
self.btnCreate.SetUp()
self.btnDelete.SetUp()
self.btnExit.SetUp()
self.btnLeft.SetUp()
self.btnRight.SetUp()
self.btnStart.Disable()
self.btnCreate.Disable()
self.btnDelete.Disable()
self.btnExit.Disable()
self.btnLeft.Disable()
self.btnRight.Disable()
self.dlgQuestion.Hide()
self.stream.SetCharacterSlot(self.slot)
self.startIndex = self.slot
self.startReservingTime = app.GetTime()
for i in range(self.SLOT_COUNT):
if False == chr.HasInstance(i):
continue
chr.SelectInstance(i)
if i == self.slot:
self.slot=self.slot
chr.PushOnceMotion(chr.MOTION_INTRO_SELECTED, 0.1)
continue
chr.PushOnceMotion(chr.MOTION_INTRO_NOT_SELECTED, 0.1)
def OpenChangeNameDialog(self):
import uiCommon
nameInputBoard = uiCommon.InputDialogWithDescription()
nameInputBoard.SetTitle(localeInfo.SELECT_CHANGE_NAME_TITLE)
nameInputBoard.SetAcceptEvent(ui.__mem_func__(self.AcceptInputName))
nameInputBoard.SetCancelEvent(ui.__mem_func__(self.CancelInputName))
nameInputBoard.SetMaxLength(chr.PLAYER_NAME_MAX_LEN)
nameInputBoard.SetBoardWidth(200)
nameInputBoard.SetDescription(localeInfo.SELECT_INPUT_CHANGING_NAME)
nameInputBoard.Open()
nameInputBoard.slot = self.slot
self.nameInputBoard = nameInputBoard
def OnChangeName(self, id, name):
self.SelectSlot(id)
self.sendedChangeNamePacket = False
self.PopupMessage(localeInfo.SELECT_CHANGED_NAME)
def AcceptInputName(self):
changeName = self.nameInputBoard.GetText()
if not changeName:
return
self.sendedChangeNamePacket = True
net.SendChangeNamePacket(self.nameInputBoard.slot, changeName)
return self.CancelInputName()
def CancelInputName(self):
self.nameInputBoard.Close()
self.nameInputBoard = None
return True
def OnCreateFailure(self, type):
self.sendedChangeNamePacket = False
if 0 == type:
self.PopupMessage(localeInfo.SELECT_CHANGE_FAILURE_STRANGE_NAME)
elif 1 == type:
self.PopupMessage(localeInfo.SELECT_CHANGE_FAILURE_ALREADY_EXIST_NAME)
elif 100 == type:
self.PopupMessage(localeInfo.SELECT_CHANGE_FAILURE_STRANGE_INDEX)
def CreateCharacter(self):
id = self.GetCharacterSlotID(self.slot)
if 0==id:
self.stream.SetCharacterSlot(self.slot)
EMPIRE_MODE = 1
if EMPIRE_MODE:
if self.__AreAllSlotEmpty():
self.stream.SetReselectEmpirePhase()
else:
self.stream.SetCreateCharacterPhase()
else:
self.stream.SetCreateCharacterPhase()
def __AreAllSlotEmpty(self):
for iSlot in range(self.SLOT_COUNT):
if 0!=net.GetAccountCharacterSlotDataInteger(iSlot, net.ACCOUNT_CHARACTER_SLOT_ID):
return 0
return 1
def PopupDeleteQuestion(self):
id = self.GetCharacterSlotID(self.slot)
if 0 == id:
return
self.dlgQuestion.Show()
self.dlgQuestion.SetTop()
def RequestDeleteCharacter(self):
self.dlgQuestion.Hide()
id = self.GetCharacterSlotID(self.slot)
if 0 == id:
self.PopupMessage(localeInfo.SELECT_EMPTY_SLOT)
return
net.SendDestroyCharacterPacket(self.slot, "1234567")
self.PopupMessage(localeInfo.SELECT_DELEING)
def InputPrivateCode(self):
import uiCommon
privateInputBoard = uiCommon.InputDialogWithDescription()
privateInputBoard.SetTitle(localeInfo.INPUT_PRIVATE_CODE_DIALOG_TITLE)
privateInputBoard.SetAcceptEvent(ui.__mem_func__(self.AcceptInputPrivateCode))
privateInputBoard.SetCancelEvent(ui.__mem_func__(self.CancelInputPrivateCode))
if ENABLE_ENGNUM_DELETE_CODE:
pass
else:
privateInputBoard.SetNumberMode()
privateInputBoard.SetSecretMode()
privateInputBoard.SetMaxLength(7)
privateInputBoard.SetBoardWidth(250)
privateInputBoard.SetDescription(localeInfo.INPUT_PRIVATE_CODE_DIALOG_DESCRIPTION)
privateInputBoard.Open()
self.privateInputBoard = privateInputBoard
def AcceptInputPrivateCode(self):
privateCode = self.privateInputBoard.GetText()
if not privateCode:
return
id = self.GetCharacterSlotID(self.slot)
if 0 == id:
self.PopupMessage(localeInfo.SELECT_EMPTY_SLOT)
return
net.SendDestroyCharacterPacket(self.slot, privateCode)
self.PopupMessage(localeInfo.SELECT_DELEING)
self.CancelInputPrivateCode()
return True
def CancelInputPrivateCode(self):
self.privateInputBoard = None
return True
def OnDeleteSuccess(self, slot):
self.PopupMessage(localeInfo.SELECT_DELETED)
self.DeleteCharacter(slot)
def OnDeleteFailure(self):
self.PopupMessage(localeInfo.SELECT_CAN_NOT_DELETE)
def DeleteCharacter(self, index):
chr.DeleteInstance(index)
self.SelectSlot(self.slot)
def ExitSelect(self):
self.dlgQuestion.Hide()
if LEAVE_BUTTON_FOR_POTAL:
if app.loggined:
self.stream.SetPhaseWindow(0)
else:
self.stream.setloginphase()
else:
self.stream.SetLoginPhase()
self.Hide()
def GetSlotIndex(self):
return self.slot
def DecreaseSlotIndex(self):
slotIndex = (self.GetSlotIndex() - 1 + self.SLOT_COUNT) % self.SLOT_COUNT
self.SelectSlot(slotIndex)
def IncreaseSlotIndex(self):
slotIndex = (self.GetSlotIndex() + 1) % self.SLOT_COUNT
self.SelectSlot(slotIndex)
def SelectSlot(self, index):
if index < 0:
return
if index >= self.SLOT_COUNT:
return
self.slot = index
chr.SelectInstance(self.slot)
for i in range(self.CHARACTER_TYPE_COUNT):
self.destNameAlpha[i] = 0.0
for i in range(self.SLOT_COUNT):
self.destRotation[(i+self.slot)%self.SLOT_COUNT] = self.SLOT_ROTATION[i]
self.destGauge = [0.0, 0.0, 0.0, 0.0]
id=net.GetAccountCharacterSlotDataInteger(self.slot, net.ACCOUNT_CHARACTER_SLOT_ID)
if 0 != id:
self.btnStart.Show()
self.btnDelete.Show()
self.btnCreate.Hide()
playTime=net.GetAccountCharacterSlotDataInteger(self.slot, net.ACCOUNT_CHARACTER_SLOT_PLAYTIME)
level=net.GetAccountCharacterSlotDataInteger(self.slot, net.ACCOUNT_CHARACTER_SLOT_LEVEL)
race=net.GetAccountCharacterSlotDataInteger(self.slot, net.ACCOUNT_CHARACTER_SLOT_RACE)
valueHTH=net.GetAccountCharacterSlotDataInteger(self.slot, net.ACCOUNT_CHARACTER_SLOT_HTH)
valueINT=net.GetAccountCharacterSlotDataInteger(self.slot, net.ACCOUNT_CHARACTER_SLOT_INT)
valueSTR=net.GetAccountCharacterSlotDataInteger(self.slot, net.ACCOUNT_CHARACTER_SLOT_STR)
valueDEX=net.GetAccountCharacterSlotDataInteger(self.slot, net.ACCOUNT_CHARACTER_SLOT_DEX)
name=net.GetAccountCharacterSlotDataString(self.slot, net.ACCOUNT_CHARACTER_SLOT_NAME)
guildID=net.GetAccountCharacterSlotDataInteger(self.slot, net.ACCOUNT_CHARACTER_SLOT_GUILD_ID)
guildName=net.GetAccountCharacterSlotDataString(self.slot, net.ACCOUNT_CHARACTER_SLOT_GUILD_NAME)
self.changeNameFlag=net.GetAccountCharacterSlotDataInteger(self.slot, net.ACCOUNT_CHARACTER_SLOT_CHANGE_NAME_FLAG)
job = chr.RaceToJob(race)
if job >= 0 and job < self.CHARACTER_TYPE_COUNT:
self.destNameAlpha[job] = 1.0
self.CharacterName.SetText(name)
self.CharacterLevel.SetText(str(level))
self.PlayTime.SetText(str(playTime))
self.CharacterHTH.SetText(str(valueHTH))
self.CharacterINT.SetText(str(valueINT))
self.CharacterSTR.SetText(str(valueSTR))
self.CharacterDEX.SetText(str(valueDEX))
if guildName:
self.GuildName.SetText(guildName)
else:
self.GuildName.SetText(localeInfo.SELECT_NOT_JOIN_GUILD)
# statesSummary = float(valueHTH + valueINT + valueSTR + valueDEX)
# if statesSummary > 0.0:
# self.destGauge = [
# float(valueHTH) / statesSummary,
# float(valueINT) / statesSummary,
# float(valueSTR) / statesSummary,
# float(valueDEX) / statesSummary
# ]
statesSummary = float(valueHTH + valueINT + valueSTR + valueDEX)
if statesSummary > 0.0:
self.destGauge =[
float(valueHTH) / 90,
float(valueINT) / 90,
float(valueSTR) / 90,
float(valueDEX) / 90
]
else:
self.InitCharacterBoard()
def InitCharacterBoard(self):
self.btnStart.Hide()
self.btnDelete.Hide()
self.btnCreate.Show()
self.CharacterName.SetText("")
self.CharacterLevel.SetText("")
self.PlayTime.SetText("")
self.CharacterHTH.SetText("")
self.CharacterINT.SetText("")
self.CharacterSTR.SetText("")
self.CharacterDEX.SetText("")
self.GuildName.SetText(localeInfo.SELECT_NOT_JOIN_GUILD)
## Event
def OnKeyDown(self, key):
if 1 == key:
self.ExitSelect()
if 2 == key:
self.SelectSlot(0)
if 3 == key:
self.SelectSlot(1)
if 4 == key:
self.SelectSlot(2)
if 5 == key:
self.SelectSlot(3)
if 28 == key:
id = net.GetAccountCharacterSlotDataInteger(self.slot, net.ACCOUNT_CHARACTER_SLOT_ID)
if 0 == id:
self.CreateCharacter()
else:
self.StartGame()
if 203 == key:
self.slot = (self.GetSlotIndex() - 1 + self.SLOT_COUNT) % self.SLOT_COUNT
self.SelectSlot(self.slot)
if 205 == key:
self.slot = (self.GetSlotIndex() + 1) % self.SLOT_COUNT
self.SelectSlot(self.slot)
return True
def OnUpdate(self):
chr.Update()
for i in range(4):
self.curGauge[i] += (self.destGauge[i] - self.curGauge[i]) / 10.0
if abs(self.curGauge[i] - self.destGauge[i]) < 0.005:
self.curGauge[i] = self.destGauge[i]
self.GaugeList[i].SetPercentage(self.curGauge[i], 1.0)
for i in range(self.CHARACTER_TYPE_COUNT):
self.curNameAlpha[i] += (self.destNameAlpha[i] - self.curNameAlpha[i]) / 10.0
self.NameList[i].SetAlpha(self.curNameAlpha[i])
for i in range(self.SLOT_COUNT):
if False == chr.HasInstance(i):
continue
chr.SelectInstance(i)
distance = 50.0
rotRadian = self.curRotation[i] * (math.pi*2) / 360.0
x = distance*math.sin(rotRadian) + distance*math.cos(rotRadian)
y = distance*math.cos(rotRadian) - distance*math.sin(rotRadian)
chr.SetPixelPosition(int(x), int(y), 30)
#####
dir = app.GetRotatingDirection(self.destRotation[i], self.curRotation[i])
rot = app.GetDegreeDifference(self.destRotation[i], self.curRotation[i])
if app.DEGREE_DIRECTION_RIGHT == dir:
self.curRotation[i] += rot / 10.0
elif app.DEGREE_DIRECTION_LEFT == dir:
self.curRotation[i] -= rot / 10.0
self.curRotation[i] = (self.curRotation[i] + 360.0) % 360.0
#######################################################
if -1 != self.startIndex:
## Temporary
## BackGroundLoading이 지원 될때까지 임시로..
if app.GetTime() - self.startReservingTime > 3.0:
if False == self.openLoadingFlag:
chrSlot=self.stream.GetCharacterSlot()
net.DirectEnter(chrSlot)
self.openLoadingFlag = True
playTime=net.GetAccountCharacterSlotDataInteger(self.slot, net.ACCOUNT_CHARACTER_SLOT_PLAYTIME)
import player
player.SetPlayTime(playTime)
import chat
chat.Clear() ## 들어갈때 Chat 을 초기화. 임시 Pos.
## Temporary
#######################################################
def EmptyFunc(self):
pass
def PopupMessage(self, msg, func=0):
if not func:
func=self.EmptyFunc
self.stream.popupWindow.Close()
self.stream.popupWindow.Open(msg, func, localeInfo.UI_OK)
def OnPressExitKey(self):
self.ExitSelect()
return True
SelectCharacterWindow._RebuildLocaleStrings()
localeInfo.RegisterReloadCallback(SelectCharacterWindow._RebuildLocaleStrings)
-481
View File
@@ -1,481 +0,0 @@
import app
import dbg
APP_GET_LOCALE_PATH = app.GetLocalePath()
APP_GET_LOCALE_PATH_COMMON = app.GetLocalePathCommon()
APP_TITLE = 'METIN2'
BLEND_POTION_NO_TIME = 'BLEND_POTION_NO_TIME'
BLEND_POTION_NO_INFO = 'BLEND_POTION_NO_INFO'
LOGIN_FAILURE_WRONG_SOCIALID = 'LOGIN_FAILURE_WRONG_SOCIALID'
LOGIN_FAILURE_SHUTDOWN_TIME = 'LOGIN_FAILURE_SHUTDOWN_TIME'
GUILD_MEMBER_COUNT_INFINITY = 'INFINITY'
GUILD_MARK_MIN_LEVEL = '3'
GUILD_BUILDING_LIST_TXT = '{:s}/GuildBuildingList.txt'.format(APP_GET_LOCALE_PATH)
FN_GM_MARK = '{:s}/effect/gm.mse'.format(APP_GET_LOCALE_PATH_COMMON)
MAP_TREE2 = 'MAP_TREE2'
ERROR_MARK_UPLOAD_NEED_RECONNECT = 'UploadMark: Reconnect to game'
ERROR_MARK_CHECK_NEED_RECONNECT = 'CheckMark: Reconnect to game'
VIRTUAL_KEY_ALPHABET_LOWERS = r"[1234567890]/qwertyuiop\=asdfghjkl;`'zxcvbnm.,"
VIRTUAL_KEY_ALPHABET_UPPERS = r"{1234567890}?QWERTYUIOP|+ASDFGHJKL:~'ZXCVBNM<>"
VIRTUAL_KEY_SYMBOLS = "!@#$%^&*()_+|{}:'<>?~"
VIRTUAL_KEY_NUMBERS = "1234567890-=\\[];',./`"
VIRTUAL_KEY_SYMBOLS_BR = "!@#$%^&*()_+|{}:'<>?~aaaaeeeiioooouuc"
# Hot-reload callback registry
_reloadCallbacks = []
def RegisterReloadCallback(callback):
"""Register a function to be called after locale strings are reloaded."""
if callback not in _reloadCallbacks:
_reloadCallbacks.append(callback)
# Multi-language hot-reload support
def LoadLocaleData():
"""
Reload all game locale text strings from locale_game.txt
Called by app.ReloadLocale() when the user changes language.
Reloads locale_game.txt and rebuilds all derived data structures.
NOTE: Does NOT fire reload callbacks. The C++ reload chain calls
localeInfo.LoadLocaleData() first, then uiScriptLocale.LoadLocaleData()
second. Callbacks are fired by uiScriptLocale.LoadLocaleData() after
BOTH modules are fully reloaded, so callbacks can safely read from
either module.
Returns:
True on success, False on failure
"""
try:
global APP_GET_LOCALE_PATH, APP_GET_LOCALE_PATH_COMMON
APP_GET_LOCALE_PATH = app.GetLocalePath()
APP_GET_LOCALE_PATH_COMMON = app.GetLocalePathCommon()
localeFilePath = "{:s}/locale_game.txt".format(APP_GET_LOCALE_PATH)
LoadLocaleFile(localeFilePath, globals())
_RebuildDerivedData()
return True
except Exception as e:
dbg.TraceError("localeInfo.LoadLocaleData failed: %s" % str(e))
return False
def FireReloadCallbacks():
"""
Fire all registered reload callbacks.
Called by uiScriptLocale.LoadLocaleData() after both locale modules
are fully reloaded, ensuring callbacks see fresh data from both
localeInfo and uiScriptLocale.
"""
for cb in _reloadCallbacks:
try:
cb()
except Exception as e:
dbg.TraceError("localeInfo reload callback failed: %s" % str(e))
# Load locale_game.txt
def LoadLocaleFile(srcFileName, localeDict):
def SNA(text):
def f(x):
return text
return f
def SA(text):
def f(x):
return text % x
return f
def SAN(text):
def f(x):
return text % x
return f
def SAA(text):
def f(x):
return text % x
return f
funcDict = {"SA": SA, "SNA": SNA, "SAA": SAA, "SAN": SAN}
lineIndex = 1
try:
lines = pack_open(srcFileName, "r").readlines()
except IOError:
dbg.LogBox("LoadLocaleError(%(srcFileName)s)" % locals())
app.Abort()
for line in lines:
if line.count("\t") == 0:
continue
try:
tokens = line[:-1].split("\t")
if len(tokens) == 2:
localeDict[tokens[0]] = tokens[1]
elif len(tokens) >= 3:
type = tokens[2].strip()
if type:
if type in funcDict:
localeDict[tokens[0]] = funcDict[type](tokens[1])
else:
localeDict[tokens[0]] = tokens[1]
else:
localeDict[tokens[0]] = tokens[1]
else:
raise RuntimeError("Unknown TokenSize")
lineIndex += 1
except:
dbg.LogBox("%s: line(%d): %s" % (srcFileName, lineIndex, line), "Error")
raise
LoadLocaleFile("{:s}/locale_game.txt".format(APP_GET_LOCALE_PATH), globals())
try:
currentLocalePath = app.GetLocalePath()
if not app.LoadLocaleData(currentLocalePath):
dbg.TraceError("localeInfo: Failed to load C++ locale data from %s" % currentLocalePath)
except Exception as e:
dbg.TraceError("localeInfo: Error loading C++ locale data: %s" % str(e))
def _RebuildDerivedData():
"""Rebuild all derived dicts/tuples/lists from current locale strings."""
global GUILD_BUILDING_LIST_TXT, FN_GM_MARK
global OPTION_PVPMODE_MESSAGE_DICT, WHISPER_ERROR, error
global JOBINFO_TITLE
global GUILDWAR_NORMAL_DESCLIST, GUILDWAR_WARP_DESCLIST, GUILDWAR_CTF_DESCLIST
global MODE_NAME_LIST, TITLE_NAME_LIST, LEVEL_LIST, HEALTH_LIST
global USE_SKILL_ERROR_TAIL_DICT, NOTIFY_MESSAGE, ATTACK_ERROR_TAIL_DICT
global SHOT_ERROR_TAIL_DICT, USE_SKILL_ERROR_CHAT_DICT
global SHOP_ERROR_DICT, STAT_MINUS_DESCRIPTION, MINIMAP_ZONE_NAME_DICT
GUILD_BUILDING_LIST_TXT = '{:s}/GuildBuildingList.txt'.format(APP_GET_LOCALE_PATH)
FN_GM_MARK = '{:s}/effect/gm.mse'.format(APP_GET_LOCALE_PATH_COMMON)
# Option pvp messages
OPTION_PVPMODE_MESSAGE_DICT = {
0: PVP_MODE_NORMAL,
1: PVP_MODE_REVENGE,
2: PVP_MODE_KILL,
3: PVP_MODE_PROTECT,
4: PVP_MODE_GUILD,
}
# Whisper messages
WHISPER_ERROR = {
1: CANNOT_WHISPER_NOT_LOGON,
2: CANNOT_WHISPER_DEST_REFUSE,
3: CANNOT_WHISPER_SELF_REFUSE,
}
# Exception of graphic device.
error = dict(
CREATE_WINDOW = GAME_INIT_ERROR_MAIN_WINDOW,
CREATE_CURSOR = GAME_INIT_ERROR_CURSOR,
CREATE_NETWORK = GAME_INIT_ERROR_NETWORK,
CREATE_ITEM_PROTO = GAME_INIT_ERROR_ITEM_PROTO,
CREATE_MOB_PROTO = GAME_INIT_ERROR_MOB_PROTO,
CREATE_NO_DIRECTX = GAME_INIT_ERROR_DIRECTX,
CREATE_DEVICE = GAME_INIT_ERROR_GRAPHICS_NOT_EXIST,
CREATE_NO_APPROPRIATE_DEVICE = GAME_INIT_ERROR_GRAPHICS_BAD_PERFORMANCE,
CREATE_FORMAT = GAME_INIT_ERROR_GRAPHICS_NOT_SUPPORT_32BIT,
NO_ERROR = str()
)
# Job information (none, skill_group1, skill_group2)
JOBINFO_TITLE = [
[JOB_WARRIOR0, JOB_WARRIOR1, JOB_WARRIOR2,],
[JOB_ASSASSIN0, JOB_ASSASSIN1, JOB_ASSASSIN2,],
[JOB_SURA0, JOB_SURA1, JOB_SURA2,],
[JOB_SHAMAN0, JOB_SHAMAN1, JOB_SHAMAN2,],
]
#if app.ENABLE_WOLFMAN_CHARACTER:
#JOBINFO_TITLE += [[JOB_WOLFMAN0,JOB_WOLFMAN1,JOB_WOLFMAN2,],]
# Guild war description
GUILDWAR_NORMAL_DESCLIST = (GUILD_WAR_USE_NORMAL_MAP, GUILD_WAR_LIMIT_30MIN, GUILD_WAR_WIN_CHECK_SCORE)
# Guild war warp description
GUILDWAR_WARP_DESCLIST = (GUILD_WAR_USE_BATTLE_MAP, GUILD_WAR_WIN_WIPE_OUT_GUILD, GUILD_WAR_REWARD_POTION)
# Guild war flag description
GUILDWAR_CTF_DESCLIST = (GUILD_WAR_USE_BATTLE_MAP, GUILD_WAR_WIN_TAKE_AWAY_FLAG1, GUILD_WAR_WIN_TAKE_AWAY_FLAG2, GUILD_WAR_REWARD_POTION)
# Mode of pvp options
MODE_NAME_LIST = (PVP_OPTION_NORMAL, PVP_OPTION_REVENGE, PVP_OPTION_KILL, PVP_OPTION_PROTECT,)
# Title name of alignment
TITLE_NAME_LIST = (PVP_LEVEL0, PVP_LEVEL1, PVP_LEVEL2, PVP_LEVEL3, PVP_LEVEL4, PVP_LEVEL5, PVP_LEVEL6, PVP_LEVEL7, PVP_LEVEL8,)
# Horse levels
LEVEL_LIST = (str(), HORSE_LEVEL1, HORSE_LEVEL2, HORSE_LEVEL3)
# Horse health
HEALTH_LIST = (HORSE_HEALTH0, HORSE_HEALTH1, HORSE_HEALTH2, HORSE_HEALTH3)
# Use-skill messages
USE_SKILL_ERROR_TAIL_DICT = {
'IN_SAFE': CANNOT_SKILL_SELF_IN_SAFE,
'NEED_TARGET': CANNOT_SKILL_NEED_TARGET,
'NEED_EMPTY_BOTTLE': CANNOT_SKILL_NEED_EMPTY_BOTTLE,
'NEED_POISON_BOTTLE': CANNOT_SKILL_NEED_POISON_BOTTLE,
'REMOVE_FISHING_ROD': CANNOT_SKILL_REMOVE_FISHING_ROD,
'NOT_YET_LEARN': CANNOT_SKILL_NOT_YET_LEARN,
'NOT_MATCHABLE_WEAPON': CANNOT_SKILL_NOT_MATCHABLE_WEAPON,
'WAIT_COOLTIME': CANNOT_SKILL_WAIT_COOLTIME,
'NOT_ENOUGH_HP': CANNOT_SKILL_NOT_ENOUGH_HP,
'NOT_ENOUGH_SP': CANNOT_SKILL_NOT_ENOUGH_SP,
'CANNOT_USE_SELF': CANNOT_SKILL_USE_SELF,
'ONLY_FOR_ALLIANCE': CANNOT_SKILL_ONLY_FOR_ALLIANCE,
'CANNOT_ATTACK_ENEMY_IN_SAFE_AREA': CANNOT_SKILL_DEST_IN_SAFE,
'CANNOT_APPROACH': CANNOT_SKILL_APPROACH,
'CANNOT_ATTACK': CANNOT_SKILL_ATTACK,
'ONLY_FOR_CORPSE': CANNOT_SKILL_ONLY_FOR_CORPSE,
'EQUIP_FISHING_ROD': CANNOT_SKILL_EQUIP_FISHING_ROD,
'NOT_HORSE_SKILL': CANNOT_SKILL_NOT_HORSE_SKILL,
'HAVE_TO_RIDE': CANNOT_SKILL_HAVE_TO_RIDE,
}
# Notify messages
NOTIFY_MESSAGE = {
'CANNOT_EQUIP_SHOP': CANNOT_EQUIP_IN_SHOP,
'CANNOT_EQUIP_EXCHANGE': CANNOT_EQUIP_IN_EXCHANGE,
}
# Attack messages
ATTACK_ERROR_TAIL_DICT = {
'IN_SAFE': CANNOT_ATTACK_SELF_IN_SAFE,
'DEST_IN_SAFE': CANNOT_ATTACK_DEST_IN_SAFE,
}
# Shot messages
SHOT_ERROR_TAIL_DICT = {
'EMPTY_ARROW': CANNOT_SHOOT_EMPTY_ARROW,
'IN_SAFE': CANNOT_SHOOT_SELF_IN_SAFE,
'DEST_IN_SAFE': CANNOT_SHOOT_DEST_IN_SAFE,
}
# Skill messages
USE_SKILL_ERROR_CHAT_DICT = {
'NEED_EMPTY_BOTTLE': SKILL_NEED_EMPTY_BOTTLE,
'NEED_POISON_BOTTLE': SKILL_NEED_POISON_BOTTLE,
'ONLY_FOR_GUILD_WAR': SKILL_ONLY_FOR_GUILD_WAR,
}
# Shop/private-shop messages
SHOP_ERROR_DICT = {
'NOT_ENOUGH_MONEY': SHOP_NOT_ENOUGH_MONEY,
'SOLDOUT': SHOP_SOLDOUT,
'INVENTORY_FULL': SHOP_INVENTORY_FULL,
'INVALID_POS': SHOP_INVALID_POS,
'NOT_ENOUGH_MONEY_EX': SHOP_NOT_ENOUGH_MONEY_EX,
}
# Character status description
STAT_MINUS_DESCRIPTION = {
'HTH-': STAT_MINUS_CON,
'INT-': STAT_MINUS_INT,
'STR-': STAT_MINUS_STR,
'DEX-': STAT_MINUS_DEX,
}
# MR-11: Complete map name list
# Map names
MINIMAP_ZONE_NAME_DICT = {
'metin2_map_a1': MAP_A1,
'map_a2': MAP_A2,
'metin2_map_a3': MAP_A3,
'metin2_map_b1': MAP_B1,
'map_b2': MAP_B2,
'metin2_map_b3': MAP_B3,
'metin2_map_c1': MAP_C1,
'map_c2': MAP_C2,
'metin2_map_c3': MAP_C3,
'map_n_snowm_01': MAP_SNOW,
'metin2_map_n_flame_01': MAP_FLAME,
'metin2_map_n_desert_01': MAP_DESERT,
'metin2_map_milgyo': MAP_TEMPLE,
'metin2_map_monkeydungeon': MAP_MONKEY_DUNGEON,
'metin2_map_monkeydungeon_02': MAP_MONKEY_DUNGEON2,
'metin2_map_monkeydungeon_03': MAP_MONKEY_DUNGEON3,
'metin2_map_spiderdungeon': MAP_SPIDER,
'metin2_map_spiderdungeon_02': MAP_SPIDERDUNGEON_02,
'metin2_map_spiderdungeon_03': MAP_SPIDERDUNGEON_03,
'metin2_map_deviltower1': MAP_DEVILTOWER1,
'metin2_map_devilsCatacomb': MAP_DEVILCATACOMB,
'metin2_map_guild_01': MAP_GUILD_01,
'metin2_map_guild_02': MAP_GUILD_02,
'metin2_map_guild_03': MAP_GUILD_03,
'metin2_guild_village_01': GUILD_VILLAGE_01,
'metin2_guild_village_02': GUILD_VILLAGE_02,
'metin2_guild_village_03': GUILD_VILLAGE_03,
'metin2_map_trent': MAP_TREE,
'metin2_map_trent02': MAP_TREE2,
'season1/metin2_map_WL_01': MAP_WL,
'season1/metin2_map_nusluck01': MAP_NUSLUCK,
'season1/metin2_map_oxevent': MAP_OXEVENT,
'metin2_map_wedding_01': MAP_WEDDING_01,
'metin2_map_bf': MAP_BATTLE_FIELD,
'metin2_map_bf_02': MAP_BATTLE_FIELD,
'metin2_map_bf_03': MAP_BATTLE_FIELD,
'Metin2_map_CapeDragonHead': MAP_CAPE,
'metin2_map_Mt_Thunder': MAP_THUNDER,
'metin2_map_dawnmistwood': MAP_DAWN,
'metin2_map_BayBlackSand': MAP_BAY,
'metin2_map_n_flame_dungeon_01': MAP_N_FLAME_DUNGEON_01,
'metin2_map_n_snow_dungeon_01': MAP_N_SNOW_DUNGEON_01,
'metin2_map_duel': MAP_DUEL,
'season2/metin2_map_skipia_dungeon_01': MAP_SKIPIA_DUNGEON_01,
'metin2_map_skipia_dungeon_02': MAP_SKIPIA_DUNGEON_02,
'metin2_map_skipia_dungeon_boss': MAP_SKIPIA_DUNGEON_BOSS,
'metin2_map_skipia_dungeon_boss2': MAP_SKIPIA_DUNGEON_BOSS_2,
}
# MR-11: -- END OF -- Complete map name list
_RebuildDerivedData()
# Path of quest icon file
def GetLetterImageName():
return "season1/icon/scroll_close.tga"
def GetLetterOpenImageName():
return "season1/icon/scroll_open.tga"
def GetLetterCloseImageName():
return "season1/icon/scroll_close.tga"
# Sell item question
def DO_YOU_SELL_ITEM(sellItemName, sellItemCount, sellItemPrice):
return DO_YOU_SELL_ITEM2 % (sellItemName, sellItemCount, NumberToMoneyString(sellItemPrice)) if (sellItemCount > 1) else DO_YOU_SELL_ITEM1 % (sellItemName, NumberToMoneyString(sellItemPrice))
# Buy item question
def DO_YOU_BUY_ITEM(buyItemName, buyItemCount, buyItemPrice):
return DO_YOU_BUY_ITEM2 % (buyItemName, buyItemCount, buyItemPrice) if (buyItemCount > 1) else DO_YOU_BUY_ITEM1 % (buyItemName, buyItemPrice)
# Notify when you can't attach a specific item.
def REFINE_FAILURE_CAN_NOT_ATTACH(attachedItemName):
return REFINE_FAILURE_CAN_NOT_ATTACH0 % (attachedItemName)
def REFINE_FAILURE_NO_SOCKET(attachedItemName):
return REFINE_FAILURE_NO_SOCKET0 % (attachedItemName)
# Drop item question
def REFINE_FAILURE_NO_GOLD_SOCKET(attachedItemName):
return REFINE_FAILURE_NO_GOLD_SOCKET0 % (attachedItemName)
# Drop item question
def HOW_MANY_ITEM_DO_YOU_DROP(dropItemName, dropItemCount):
return HOW_MANY_ITEM_DO_YOU_DROP2 % (dropItemName, dropItemCount) if (dropItemCount > 1) else HOW_MANY_ITEM_DO_YOU_DROP1 % (dropItemName)
# Fishing notify when looks like the fish is hooked.
def FISHING_NOTIFY(isFish, fishName):
return FISHING_NOTIFY1 % (fishName) if isFish else FISHING_NOTIFY2 % (fishName)
# Fishing notify when you capture a fish.
def FISHING_SUCCESS(isFish, fishName):
return FISHING_SUCCESS1 % (fishName) if isFish else FISHING_SUCCESS2 % (fishName)
# Convert a integer amount into a string and add . as separator for money.
def NumberToMoneyString(n):
return '0 {:s}'.format(MONETARY_UNIT0) if (n <= 0) else '{:s} {:s}'.format('.'.join([(i - 3) < 0 and str(n)[:i] or str(n)[i - 3 : i] for i in range(len(str(n)) % 3, len(str(n)) + 1, 3) if i]), MONETARY_UNIT0)
# Convert a integer amount into a string and add . as separator for secondary coin.
def NumberToSecondaryCoinString(n):
return '0 {:s}'.format(MONETARY_UNIT_JUN) if (n <= 0) else '{:s} {:s}'.format('.'.join([(i - 3) < 0 and str(n)[:i] or str(n)[i - 3: i] for i in range(len(str(n)) % 3, len(str(n)) + 1, 3) if i]), MONETARY_UNIT_JUN)
# Return the title of alignment by points.
def GetAlignmentTitleName(alignment):
if alignment >= 12000:
return TITLE_NAME_LIST[0]
elif alignment >= 8000:
return TITLE_NAME_LIST[1]
elif alignment >= 4000:
return TITLE_NAME_LIST[2]
elif alignment >= 1000:
return TITLE_NAME_LIST[3]
elif alignment >= 0:
return TITLE_NAME_LIST[4]
elif alignment > -4000:
return TITLE_NAME_LIST[5]
elif alignment > -8000:
return TITLE_NAME_LIST[6]
elif alignment > -12000:
return TITLE_NAME_LIST[7]
return TITLE_NAME_LIST[8]
# Convert seconds to Days-Hours-Minutes
def SecondToDHM(time):
if time < 60:
return '0' + MINUTE
minute = (time // 60) % 60
hour = ((time // 60) // 60) % 24
day = ((time // 60) // 60) // 24
text = ''
if day > 0:
text += str(day) + DAY
text += ' '
if hour > 0:
text += str(hour) + HOUR
text += ' '
if minute > 0:
text += str(minute) + MINUTE
return text
# Convert seconds to Hours-Minutes
def SecondToHM(time):
if time < 60:
return '0' + MINUTE
minute = (time // 60) % 60
hour = (time // 60) // 60
text = ''
if hour > 0:
text += str(hour) + HOUR
if hour > 0:
text += ' '
if minute > 0:
text += str(minute) + MINUTE
return text
# Convert seconds to Days-Hours-Minutes-Seconds in real time
def RTSecondToDHMS(time):
text = ""
d = time // (24 * 3600)
time %= (24 * 3600)
h = time // 3600
time %= 3600
m = time // 60
s = time % 60
if d or not text:
if d:
text += str(d) + " " + DAY + (", " if h or m or s else "")
if h or not text:
if h:
text += str(h) + " " + HOUR + (", " if m or s else "")
if m or not text:
if m:
text += str(m) + " " + MINUTE + (", " if s else "")
if s or not text:
if s:
text += str(s) + " " + SECOND
return text.strip()
@@ -1,102 +0,0 @@
FolderName "pack"
List ExcludedFolderNameList
{
"CVS"
}
List ExcludedFileNameList
{
"vssver.scc"
"syserr.txt"
"soundscript.txt"
"log.txt"
"Test.py"
"Prototype[OffLine].py"
"loginInfo.py"
"error_lookup.py"
"errorlog.txt"
"makepackscript.txt"
"makepackscript_onlyroot.txt"
"moviemakepackscript.txt"
"build_mottable.py"
"uitest.py"
"packall.txt"
"packitem.txt"
"packpc.txt"
"packroot.txt"
"test.txt"
"test2.txt"
"quest_test.py"
}
List SecurityExtNameList
{
"txt"
"msk"
"msa"
"msm"
"py"
}
List CompressExtNameList
{
"txt"
"msk"
"mss"
"mse"
"msf"
"msa"
"spt"
"atr"
"dds"
"raw"
"wtr"
"mde"
"tga"
}
Group RootPackItemList
{
Group ItemProto
{
FileName "*item_proto"
Fixed TRUE
}
Group mob_proto
{
FileName "*mob_proto"
Fixed TRUE
}
Group TextureSet
{
FileName "TextureSet/*.txt"
Fixed TRUE
}
Group TextFiles
{
FileName "*.txt"
Fixed TRUE
}
Group TextFiles
{
FileName "*.tbl"
Fixed TRUE
}
Group KoreanFiles
{
FileName "*.cvt"
Fixed TRUE
}
Group ModelFiles
{
FileName "*.msm"
Fixed TRUE
}
}
Group PackList
{
Group UIScript
{
PathName "UIScript/*"
Fixed TRUE
}
}
-405
View File
@@ -1,405 +0,0 @@
import app
import grp
import grpImage
import item
import wndMgr
import player
import skill
import dbg
import grpText
import ui
import systemSetting
import localeInfo
## Mouse Controller
## When operating the mouse cursor, you can exchange information with the attached Object.
class CursorImage(object):
def __init__(self):
self.handle = 0
def __init__(self, imageName):
self.handle = 0
self.LoadImage(imageName)
# MR-10: Fix mouse destruction
def __del__(self):
try:
if grpImage and self.handle and hasattr(grpImage, "Delete"):
grpImage.Delete(self.handle)
except:
pass
# MR-10: -- END OF -- Fix mouse destruction
def LoadImage(self, imageName):
try:
self.handle = grpImage.Generate(imageName)
except:
import sys
dbg.TraceError("%s %s" % (sys.exc_info()[0], sys.exc_info()[1]))
self.handle = 0
def DeleteImage(self):
if self.handle:
grpImage.Delete(self.handle)
def IsImage(self):
if self.handle:
return True
return False
def SetPosition(self, x, y):
if self.handle:
grpImage.SetPosition(self.handle, x, y)
def Render(self):
if self.handle:
grpImage.Render(self.handle)
class CMouseController(object):
def __init__(self):
self.x = 0
self.y = 0
self.IsSoftwareCursor = False
self.curCursorName = ""
self.curCursorImage = 0
self.cursorPosX = 0
self.cursorPosY = 0
self.AttachedIconHandle = 0
self.AttachedOwner = 0
self.AttachedFlag = False
self.AttachedType = 0
self.AttachedSlotNumber = 0
self.AttachedCount = 1
self.AttachedIconHalfWidth = 0
self.AttachedIconHalfHeight = 0
self.LastAttachedSlotNumber = 0
self.countNumberLine = None
self.DeattachObject()
self.callbackDict = {}
def __del__(self):
self.callbackDict = {}
def Create(self):
self.IsSoftwareCursor = systemSetting.IsSoftwareCursor()
self.cursorDict = {
app.NORMAL : CursorImage("D:/Ymir Work/UI/Cursor/cursor.sub"),
app.ATTACK : CursorImage("D:/Ymir Work/UI/Cursor/cursor_attack.sub"),
app.TARGET : CursorImage("D:/Ymir Work/UI/Cursor/cursor_attack.sub"),
app.TALK : CursorImage("D:/Ymir Work/UI/Cursor/cursor_talk.sub"),
app.CANT_GO : CursorImage("D:/Ymir Work/UI/Cursor/cursor_no.sub"),
app.PICK : CursorImage("D:/Ymir Work/UI/Cursor/cursor_pick.sub"),
app.DOOR : CursorImage("D:/Ymir Work/UI/Cursor/cursor_door.sub"),
app.CHAIR : CursorImage("D:/Ymir Work/UI/Cursor/cursor_chair.sub"),
app.MAGIC : CursorImage("D:/Ymir Work/UI/Cursor/cursor_chair.sub"),
app.BUY : CursorImage("D:/Ymir Work/UI/Cursor/cursor_buy.sub"),
app.SELL : CursorImage("D:/Ymir Work/UI/Cursor/cursor_sell.sub"),
app.CAMERA_ROTATE : CursorImage("D:/Ymir Work/UI/Cursor/cursor_camera_rotate.sub"),
app.HSIZE : CursorImage("D:/Ymir Work/UI/Cursor/cursor_hsize.sub"),
app.VSIZE : CursorImage("D:/Ymir Work/UI/Cursor/cursor_vsize.sub"),
app.HVSIZE : CursorImage("D:/Ymir Work/UI/Cursor/cursor_hvsize.sub"),
}
self.cursorPosDict = {
app.NORMAL : (0, 0),
app.TARGET : (0, 0),
app.ATTACK : (0, 0),
app.TALK : (0, 0),
app.CANT_GO : (0, 0),
app.PICK : (0, 0),
app.DOOR : (0, 0),
app.CHAIR : (0, 0),
app.MAGIC : (0, 0),
app.BUY : (0, 0),
app.SELL : (0, 0),
app.CAMERA_ROTATE : (0, 0),
app.HSIZE : (-16, -16),
app.VSIZE : (-16, -16),
app.HVSIZE : (-16, -16),
}
app.SetCursor(app.NORMAL)
"""
AttachedCountTextLineHandle = grpText.Generate()
grpText.SetFontName(AttachedCountTextLineHandle, localeInfo.UI_DEF_FONT_SMALL)
grpText.SetText(AttachedCountTextLineHandle, "1234")
grpText.SetPosition(AttachedCountTextLineHandle, 100, 100)
grpText.SetOutline(AttachedCountTextLineHandle, True)
grpText.SetFontColor(AttachedCountTextLineHandle, 1.0, 1.0, 1.0)
grpText.SetHorizontalAlign(AttachedCountTextLineHandle, wndMgr.TEXT_HORIZONTAL_ALIGN_CENTER)
self.AttachedCountTextLineHandle = AttachedCountTextLineHandle
"""
self.countNumberLine = ui.NumberLine("CURTAIN")
self.countNumberLine.SetHorizontalAlignCenter()
self.countNumberLine.Hide()
return True
# Cursor Control
def ChangeCursor(self, cursorNum):
try:
self.curCursorNum = cursorNum
self.curCursorImage = self.cursorDict[cursorNum]
(self.cursorPosX, self.cursorPosY) = self.cursorPosDict[cursorNum]
if False == self.curCursorImage.IsImage():
self.curCursorNum = app.NORMAL
self.curCursorImage = self.cursorDict[app.NORMAL]
except KeyError:
dbg.TraceError("mouseModule.MouseController.SetCursor - Invalid cursor number [%d]" % cursorNum)
self.curCursorName = app.NORMAL
self.curCursorImage = self.cursorDict[app.NORMAL]
# Attaching
def AttachObject(self, Owner, Type, SlotNumber, ItemIndex, count = 0):
self.LastAttachedSlotNumber = self.AttachedSlotNumber
self.AttachedFlag = True
self.AttachedOwner = Owner
self.AttachedType = Type
self.AttachedSlotNumber = SlotNumber
self.AttachedItemIndex = ItemIndex
self.AttachedCount = count
self.countNumberLine.SetNumber("")
self.countNumberLine.Hide()
if count > 1:
self.countNumberLine.SetNumber(str(count))
self.countNumberLine.Show()
try:
width = 1
height = 1
if Type == player.SLOT_TYPE_INVENTORY or\
Type == player.SLOT_TYPE_PRIVATE_SHOP or\
Type == player.SLOT_TYPE_SHOP or\
Type == player.SLOT_TYPE_SAFEBOX or\
Type == player.SLOT_TYPE_MALL or\
Type == player.SLOT_TYPE_DRAGON_SOUL_INVENTORY:
item.SelectItem(self.AttachedItemIndex)
self.AttachedIconHandle = item.GetIconInstance()
if not self.AttachedIconHandle:
self.AttachedIconHandle = 0
self.DeattachObject()
return
(width, height) = item.GetItemSize()
elif Type == player.SLOT_TYPE_SKILL:
skillGrade = player.GetSkillGrade(SlotNumber)
self.AttachedIconHandle = skill.GetIconInstanceNew(self.AttachedItemIndex, skillGrade)
elif Type == player.SLOT_TYPE_EMOTION:
image = player.GetEmotionIconImage(ItemIndex)
self.AttachedIconHandle = grpImage.GenerateFromHandle(image)
elif Type == player.SLOT_TYPE_QUICK_SLOT:
(quickSlotType, position) = player.GetGlobalQuickSlot(SlotNumber)
if quickSlotType == player.SLOT_TYPE_INVENTORY:
itemIndex = player.GetItemIndex(position)
item.SelectItem(itemIndex)
self.AttachedIconHandle = item.GetIconInstance()
(width, height) = item.GetItemSize()
elif quickSlotType == player.SLOT_TYPE_SKILL:
skillIndex = player.GetSkillIndex(position)
skillGrade = player.GetSkillGrade(position)
self.AttachedIconHandle = skill.GetIconInstanceNew(skillIndex, skillGrade)
elif quickSlotType == player.SLOT_TYPE_EMOTION:
image = player.GetEmotionIconImage(position)
self.AttachedIconHandle = grpImage.GenerateFromHandle(image)
if not self.AttachedIconHandle:
self.DeattachObject()
return
self.AttachedIconHalfWidth = grpImage.GetWidth(self.AttachedIconHandle) / 2
self.AttachedIconHalfHeight = grpImage.GetHeight(self.AttachedIconHandle) / 2
self.AttachedIconHalfWidth = grpImage.GetWidth(self.AttachedIconHandle) / 2
self.AttachedIconHalfHeight = grpImage.GetHeight(self.AttachedIconHandle) / 2
wndMgr.AttachIcon(self.AttachedType, self.AttachedItemIndex, self.AttachedSlotNumber, width, height)
except Exception as e:
dbg.TraceError("mouseModule.py: AttachObject : " + str(e))
self.AttachedIconHandle = 0
def IsAttachedMoney(self):
if True == self.isAttached():
if player.ITEM_MONEY == self.GetAttachedItemIndex():
return True
return False
def GetAttachedMoneyAmount(self):
if True == self.isAttached():
if player.ITEM_MONEY == self.GetAttachedItemIndex():
return self.GetAttachedItemCount()
return 0
def AttachMoney(self, owner, type, count):
self.LastAttachedSlotNumber = self.AttachedSlotNumber
self.AttachedFlag = True
self.AttachedOwner = owner
self.AttachedType = type
self.AttachedSlotNumber = -1
self.AttachedItemIndex = player.ITEM_MONEY
self.AttachedCount = count
self.AttachedIconHandle = grpImage.Generate("icon/item/money.tga")
self.AttachedIconHalfWidth = grpImage.GetWidth(self.AttachedIconHandle) / 2
self.AttachedIconHalfHeight = grpImage.GetHeight(self.AttachedIconHandle) / 2
wndMgr.AttachIcon(self.AttachedType, self.AttachedItemIndex, self.AttachedSlotNumber, 1, 1)
if count > 1:
self.countNumberLine.SetNumber(str(count))
self.countNumberLine.Show()
#grpText.SetText(self.AttachedCountTextLineHandle, str(count))
def DeattachObject(self):
self.ClearCallBack()
self.LastAttachedSlotNumber = self.AttachedSlotNumber
if self.AttachedIconHandle != 0:
if self.AttachedType == player.SLOT_TYPE_INVENTORY or\
self.AttachedType == player.SLOT_TYPE_PRIVATE_SHOP or\
self.AttachedType == player.SLOT_TYPE_SHOP or\
self.AttachedType == player.SLOT_TYPE_SAFEBOX or\
self.AttachedType == player.SLOT_TYPE_MALL:
item.DeleteIconInstance(self.AttachedIconHandle)
elif self.AttachedType == player.SLOT_TYPE_SKILL:
skill.DeleteIconInstance(self.AttachedIconHandle)
elif self.AttachedType == player.SLOT_TYPE_EMOTION:
grpImage.Delete(self.AttachedIconHandle)
self.AttachedFlag = False
self.AttachedType = -1
self.AttachedItemIndex = -1
self.AttachedSlotNumber = -1
self.AttachedIconHandle = 0
wndMgr.SetAttachingFlag(False)
if self.countNumberLine:
self.countNumberLine.Hide()
def isAttached(self):
return self.AttachedFlag
def GetAttachedOwner(self):
if False == self.isAttached():
return 0
return self.AttachedOwner
def GetAttachedType(self):
if False == self.isAttached():
return player.SLOT_TYPE_NONE
return self.AttachedType
def GetAttachedSlotNumber(self):
if False == self.isAttached():
return 0
return self.AttachedSlotNumber
def GetLastAttachedSlotNumber(self):
return self.LastAttachedSlotNumber
def GetAttachedItemIndex(self):
if False == self.isAttached():
return 0
return self.AttachedItemIndex
def GetAttachedItemCount(self):
if False == self.isAttached():
return 0
return self.AttachedCount
# Update
def Update(self, x, y):
self.x = x
self.y = y
if True == self.isAttached():
if 0 != self.AttachedIconHandle:
grpImage.SetDiffuseColor(self.AttachedIconHandle, 1.0, 1.0, 1.0, 0.5)
grpImage.SetPosition(self.AttachedIconHandle, self.x - self.AttachedIconHalfWidth, self.y - self.AttachedIconHalfHeight)
self.countNumberLine.SetPosition(self.x, self.y - self.AttachedIconHalfHeight - 3)
if self.IsSoftwareCursor:
if 0 != self.curCursorImage:
self.curCursorImage.SetPosition(self.x + self.cursorPosX, self.y + self.cursorPosY)
# Render
def Render(self):
if True == self.isAttached():
if 0 != self.AttachedIconHandle:
grpImage.Render(self.AttachedIconHandle)
if self.IsSoftwareCursor:
if True == app.IsShowCursor():
if 0 != self.curCursorImage:
self.curCursorImage.Render()
else:
if False == app.IsShowCursor():
if True == app.IsLiarCursorOn():
if 0 != self.curCursorImage:
self.curCursorImage.SetPosition(self.x + self.cursorPosX, self.y + self.cursorPosY)
self.curCursorImage.Render()
def SetCallBack(self, type, event=lambda *arg:None):
self.callbackDict[type] = event
def RunCallBack(self, type, *arg):
if type not in self.callbackDict:
self.DeattachObject()
return
self.callbackDict[type]()
def ClearCallBack(self):
self.callbackDict = {}
mouseController = CMouseController()
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
-27
View File
@@ -1,27 +0,0 @@
METIN2THEMA = "M2BG.mp3"
loginMusic="login_window.mp3"
createMusic="characterselect.mp3"
selectMusic="characterselect.mp3"
fieldMusic=METIN2THEMA
def SaveLastPlayFieldMusic():
global fieldMusic
try:
with open("BGM/lastplay.inf", "w") as lastPlayFile:
lastPlayFile.write(fieldMusic)
except IOError:
return
def LoadLastPlayFieldMusic():
global fieldMusic
try:
with open("BGM/lastplay.inf", "r") as lastPlayFile:
fieldMusic=lastPlayFile.read()
except IOError:
return
-305
View File
@@ -1,305 +0,0 @@
###################################################################################################
# Network
import app
import chr
import dbg
import net
import snd
import chr
import chrmgr
import background
import player
import playerSettingModule
import ui
import uiPhaseCurtain
import localeInfo
class PopupDialog(ui.ScriptWindow):
# MR-15: Multiline dialog messages
BASE_HEIGHT = 105
BASE_WIDTH = 280
BUTTON_Y = 63
LINE_HEIGHT = 12
# MR-15: -- END OF -- Multiline dialog messages
def __init__(self):
print("NEW POPUP DIALOG ----------------------------------------------------------------------------")
ui.ScriptWindow.__init__(self)
self.CloseEvent = 0
def __del__(self):
print("---------------------------------------------------------------------------- DELETE POPUP DIALOG ")
ui.ScriptWindow.__del__(self)
def LoadDialog(self):
PythonScriptLoader = ui.PythonScriptLoader()
PythonScriptLoader.LoadScriptFile(self, "UIScript/PopupDialog.py")
def Open(self, Message, event = 0, ButtonName = None):
if ButtonName is None:
ButtonName = localeInfo.UI_CANCEL
if True == self.IsShow():
self.Close()
self.Lock()
self.SetTop()
self.CloseEvent = event
AcceptButton = self.GetChild("accept")
AcceptButton.SetText(ButtonName)
AcceptButton.SetEvent(ui.__mem_func__(self.Close))
# MR-15: Multiline dialog messages
messageWidget = self.GetChild("message")
messageWidget.SetText(Message)
extraH = len(messageWidget.extraLines) * self.LINE_HEIGHT + 2
newH = self.BASE_HEIGHT + extraH
self.SetSize(self.BASE_WIDTH, newH)
self.GetChild("board").SetSize(self.BASE_WIDTH, newH)
AcceptButton.SetPosition(0, self.BUTTON_Y + extraH)
self.SetCenterPosition()
self.UpdateRect()
# MR-15: -- END OF -- Multiline dialog messages
self.Show()
def Close(self):
if False == self.IsShow():
self.CloseEvent = 0
return
self.Unlock()
self.Hide()
if 0 != self.CloseEvent:
self.CloseEvent()
self.CloseEvent = 0
def Destroy(self):
self.Close()
self.ClearDictionary()
def OnPressEscapeKey(self):
self.Close()
return True
def OnIMEReturn(self):
self.Close()
return True
##
## Main Stream
##
class MainStream(object):
isChrData=0
def __init__(self):
print("NEWMAIN STREAM ----------------------------------------------------------------------------")
net.SetHandler(self)
net.SetTCPRecvBufferSize(128*1024)
net.SetTCPSendBufferSize(4096)
self.id=""
self.pwd=""
self.addr=""
self.port=0
self.account_addr=0
self.account_port=0
self.slot=0
self.isAutoSelect=0
self.isAutoLogin=0
self.curtain = 0
self.curPhaseWindow = 0
self.newPhaseWindow = 0
def __del__(self):
print("---------------------------------------------------------------------------- DELETE MAIN STREAM ")
def Destroy(self):
if self.curPhaseWindow:
self.curPhaseWindow.Close()
self.curPhaseWindow = 0
if self.newPhaseWindow:
self.newPhaseWindow.Close()
self.newPhaseWindow = 0
self.popupWindow.Destroy()
self.popupWindow = 0
self.curtain = 0
def Create(self):
self.CreatePopupDialog()
self.curtain = uiPhaseCurtain.PhaseCurtain()
def SetPhaseWindow(self, newPhaseWindow):
if self.newPhaseWindow:
#print "Already in the process of changing to a new phase, skip", newPhaseWindow
self.__ChangePhaseWindow()
self.newPhaseWindow=newPhaseWindow
if self.curPhaseWindow:
#print "Change after fade out"
self.curtain.FadeOut(self.__ChangePhaseWindow)
else:
#print "Change immediately if there's no current phase"
self.__ChangePhaseWindow()
def __ChangePhaseWindow(self):
oldPhaseWindow=self.curPhaseWindow
newPhaseWindow=self.newPhaseWindow
self.curPhaseWindow=0
self.newPhaseWindow=0
if oldPhaseWindow:
oldPhaseWindow.Close()
if newPhaseWindow:
newPhaseWindow.Open()
self.curPhaseWindow=newPhaseWindow
if self.curPhaseWindow:
self.curtain.FadeIn()
else:
app.Exit()
def CreatePopupDialog(self):
self.popupWindow = PopupDialog()
self.popupWindow.LoadDialog()
self.popupWindow.SetCenterPosition()
self.popupWindow.Hide()
## SelectPhase
##########################################################################################
def SetLoginPhase(self):
net.Disconnect()
import introLogin
self.SetPhaseWindow(introLogin.LoginWindow(self))
def SameLogin_SetLoginPhase(self):
net.Disconnect()
import introLogin
introInst = introLogin.LoginWindow(self)
self.SetPhaseWindow(introInst)
introInst.SameLogin_OpenUI()
def SetSelectEmpirePhase(self):
try:
import introEmpire
self.SetPhaseWindow(introEmpire.SelectEmpireWindow(self))
except:
import exception
exception.Abort("networkModule.SetSelectEmpirePhase")
def SetReselectEmpirePhase(self):
try:
import introEmpire
self.SetPhaseWindow(introEmpire.ReselectEmpireWindow(self))
except:
import exception
exception.Abort("networkModule.SetReselectEmpirePhase")
def SetSelectCharacterPhase(self):
try:
localeInfo.LoadLocaleData()
import introSelect
self.popupWindow.Close()
self.SetPhaseWindow(introSelect.SelectCharacterWindow(self))
except:
import exception
exception.Abort("networkModule.SetSelectCharacterPhase")
def SetCreateCharacterPhase(self):
try:
import introCreate
self.SetPhaseWindow(introCreate.CreateCharacterWindow(self))
except:
import exception
exception.Abort("networkModule.SetCreateCharacterPhase")
def SetTestGamePhase(self, x, y):
try:
import introLoading
loadingPhaseWindow=introLoading.LoadingWindow(self)
loadingPhaseWindow.LoadData(x, y)
self.SetPhaseWindow(loadingPhaseWindow)
except:
import exception
exception.Abort("networkModule.SetLoadingPhase")
def SetLoadingPhase(self):
try:
import introLoading
self.SetPhaseWindow(introLoading.LoadingWindow(self))
except:
import exception
exception.Abort("networkModule.SetLoadingPhase")
def SetGamePhase(self):
try:
import game
self.popupWindow.Close()
self.SetPhaseWindow(game.GameWindow(self))
except:
raise
import exception
exception.Abort("networkModule.SetGamePhase")
################################
# Functions used in python
## Login
def Connect(self):
import constInfo
if constInfo.KEEP_ACCOUNT_CONNETION_ENABLE:
net.ConnectToAccountServer(self.addr, self.port, self.account_addr, self.account_port)
else:
net.ConnectTCP(self.addr, self.port)
#net.ConnectUDP(IP, Port)
def SetConnectInfo(self, addr, port, account_addr=0, account_port=0):
self.addr = addr
self.port = port
self.account_addr = account_addr
self.account_port = account_port
def GetConnectAddr(self):
return self.addr
def SetLoginInfo(self, id, pwd):
self.id = id
self.pwd = pwd
net.SetLoginInfo(id, pwd)
def CancelEnterGame(self):
pass
## Select
def SetCharacterSlot(self, slot):
self.slot=slot
def GetCharacterSlot(self):
return self.slot
## Empty
def EmptyFunction(self):
pass
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
-61
View File
@@ -1,61 +0,0 @@
import dbg
import app
import localeInfo
import wndMgr
import systemSetting
import mouseModule
import networkModule
import uiCandidate
import constInfo
import musicInfo
import stringCommander
#bind_me(locals().values())
def RunApp():
musicInfo.LoadLastPlayFieldMusic()
app.SetHairColorEnable(constInfo.HAIR_COLOR_ENABLE)
app.SetArmorSpecularEnable(constInfo.ARMOR_SPECULAR_ENABLE)
app.SetWeaponSpecularEnable(constInfo.WEAPON_SPECULAR_ENABLE)
app.SetMouseHandler(mouseModule.mouseController)
wndMgr.SetMouseHandler(mouseModule.mouseController)
wndMgr.SetScreenSize(systemSetting.GetWidth(), systemSetting.GetHeight())
try:
app.Create(localeInfo.APP_TITLE, systemSetting.GetWidth(), systemSetting.GetHeight(), 1)
except RuntimeError as msg:
msg = str(msg)
if "CREATE_DEVICE" == msg:
dbg.LogBox("Sorry, Your system does not support 3D graphics,\r\nplease check your hardware and system configeration\r\nthen try again.")
else:
dbg.LogBox("Metin2.%s" % msg)
return
app.SetCamera(1500.0, 30.0, 0.0, 180.0)
#Gets and sets the floating-point control word
#app.SetControlFP()
if not mouseModule.mouseController.Create():
return
mainStream = networkModule.MainStream()
mainStream.Create()
#mainStream.SetLoadingPhase()
mainStream.SetLoginPhase()
#mainStream.SetSelectCharacterPhase()
#mainStream.SetCreateCharacterPhase()
#mainStream.SetSelectEmpirePhase()
#mainStream.SetGamePhase()
app.Loop()
mainStream.Destroy()
RunApp()
-39
View File
@@ -1,39 +0,0 @@
import sys
libpath = '..\\..\\Extern\\Py2Lib\\lib'
sys.path.append(libpath)
#import utils
import imp
fp, pathname, description = imp.find_module('utils', [libpath])
utils = imp.load_module('utils', fp, pathname, description)
import cythonizer
pys = utils.findMatchedFiles(".", "*.py")
pys.remove('RootlibCythonizer.py')
moduleLst = cythonizer.run(pys, forceRecompile=True)
moduleNameLst = []
sourceFileLst = []
import os.path
for m in moduleLst:
for source in m.sources:
base, ext = os.path.splitext(source)
moduleName = base.split('/')[-1]
moduleNameLst.append(moduleName)
sourceFileLst.append(base + (".cpp" if "c++" == m.language else ".c"))
import sourceWriter
sourceFileName = sourceWriter.run(moduleNameLst, 'rootlib')
print(("%s create successful." % sourceFileName))
# not yet implemented.
#from distutils.dist import Distribution
#dist = Distribution({'name' : 'test', 'libraries' : [('test', {'sources' : sourceFileLst})]})
#from builder import Builder
#cBuilder = Builder(dist)
#cBuilder.run()
#import builder
#builder.run(sourceFileLst, 'test')
-58
View File
@@ -1,58 +0,0 @@
import net
import background
import stringCommander
import constInfo
class ServerCommandParser(object):
def __init__(self):
net.SetServerCommandParserWindow(self)
self.__ServerCommand_Build()
def __ServerCommand_Build(self):
serverCommandList={
"DayMode" : self.__DayMode_Update,
"xmas_snow" : self.__XMasSnow_Enable,
"xmas_boom" : self.__XMasBoom_Enable,
"xmas_tree" : self.__XMasTree_Enable,
"newyear_boom" : self.__XMasBoom_Enable,
"item_mall" : self.__ItemMall_Open,
}
self.serverCommander=stringCommander.Analyzer()
for serverCommandItem in list(serverCommandList.items()):
self.serverCommander.SAFE_RegisterCallBack(
serverCommandItem[0], serverCommandItem[1]
)
def BINARY_ServerCommand_Run(self, line):
try:
print((" BINARY_ServerCommand_Reserve", line))
return self.serverCommander.Run(line)
except RuntimeError as msg:
import dbg
dbg.TraceError(msg)
return 0
def __PreserveCommand(self, line):
net.PreserveServerCommand(line)
def __DayMode_Update(self, mode):
self.__PreserveCommand("PRESERVE_DayMode " + mode)
def __ItemMall_Open(self):
self.__PreserveCommand("item_mall")
## 임시
def __XMasBoom_Enable(self, mode):
if "1"==mode:
self.__PreserveCommand("PRESERVE_DayMode dark")
else:
self.__PreserveCommand("PRESERVE_DayMode light")
def __XMasSnow_Enable(self, mode):
self.__PreserveCommand("xmas_snow " + mode)
def __XMasTree_Enable(self, grade):
self.__PreserveCommand("xmas_tree " + grade)
parserWnd = ServerCommandParser()
-59
View File
@@ -1,59 +0,0 @@
SERVER_NAME = "Metin2"
SERVER_NAME_TEST = "Test"
SERVER_IP = "178.18.255.214"
SERVER_IP_TEST = "127.0.0.1"
CH1_NAME = "CH1"
CH2_NAME = "CH2"
CH3_NAME = "CH3"
CH4_NAME = "CH4"
PORT_1 = 11011
PORT_2 = 11021
PORT_3 = 11031
PORT_4 = 11041
PORT_AUTH = 11000
PORT_MARK = 11011
STATE_NONE = "..."
STATE_DICT = {
0 : "....",
1 : "NORM",
2 : "BUSY",
3 : "FULL"
}
SERVER01_CHANNEL_DICT = {
1:{"key":11,"name":CH1_NAME,"ip":SERVER_IP,"tcp_port":PORT_1,"udp_port":PORT_1,"state":STATE_NONE,},
2:{"key":12,"name":CH2_NAME,"ip":SERVER_IP,"tcp_port":PORT_2,"udp_port":PORT_2,"state":STATE_NONE,},
3:{"key":13,"name":CH3_NAME,"ip":SERVER_IP,"tcp_port":PORT_3,"udp_port":PORT_3,"state":STATE_NONE,},
4:{"key":14,"name":CH4_NAME,"ip":SERVER_IP,"tcp_port":PORT_4,"udp_port":PORT_4,"state":STATE_NONE,},
}
SERVER02_CHANNEL_DICT = {
1:{"key":21,"name":CH1_NAME,"ip":SERVER_IP_TEST,"tcp_port":PORT_1,"udp_port":PORT_1,"state":STATE_NONE,},
2:{"key":22,"name":CH2_NAME,"ip":SERVER_IP_TEST,"tcp_port":PORT_2,"udp_port":PORT_2,"state":STATE_NONE,},
}
REGION_NAME_DICT = {
0 : "",
}
REGION_AUTH_SERVER_DICT = {
0 : {
1 : { "ip":SERVER_IP, "port":PORT_AUTH, },
2 : { "ip":SERVER_IP_TEST, "port":PORT_AUTH, },
}
}
REGION_DICT = {
0 : {
1 : { "name" :SERVER_NAME, "channel" : SERVER01_CHANNEL_DICT, },
2 : { "name" :SERVER_NAME_TEST, "channel" : SERVER02_CHANNEL_DICT, },
},
}
MARKADDR_DICT = {
10 : { "ip" : SERVER_IP, "tcp_port" : PORT_MARK, "mark" : "10.tga", "symbol_path" : "10", },
20 : { "ip" : SERVER_IP_TEST, "tcp_port" : PORT_MARK, "mark" : "20.tga", "symbol_path" : "20", },
}
-65
View File
@@ -1,65 +0,0 @@
import _weakref
class CallBackFunction:
class __noarg_call__:
def __init__(self, cls, obj, func):
self.cls=cls
self.obj=_weakref.proxy(obj)
self.func=_weakref.proxy(func)
def __call__(self, *arg):
return self.func(self.obj)
class __arg_call__:
def __init__(self, cls, obj, func):
self.cls=cls
self.obj=_weakref.proxy(obj)
self.func=_weakref.proxy(func)
def __call__(self, *arg):
return self.func(self.obj, *arg)
def __init__(self, mfunc):
self.argCount=mfunc.__func__.__code__.co_argcount
if self.argCount>1:
self.call=CallBackFunction.__arg_call__(mfunc.__self__.__class__, mfunc.__self__, mfunc.__func__)
else:
self.call=CallBackFunction.__noarg_call__(mfunc.__self__.__class__, mfunc.__self__, mfunc.__func__)
def __call__(self, *arg):
return self.call(*arg)
def GetArgumentCount(self):
return self.argCount
class Analyzer:
def __init__(self):
self.cmdDict={}
def SAFE_RegisterCallBack(self, cmd, callBackFunc):
self.cmdDict[cmd]=CallBackFunction(callBackFunc)
def Run(self, line):
tokens=line.split()
if len(tokens)==0:
return 1
cmd=tokens.pop(0)
try:
callBackFunc=self.cmdDict[cmd]
except KeyError:
return 0
argCount=callBackFunc.GetArgumentCount()-1
if len(tokens)<argCount:
raise RuntimeError("Analyzer.Run(line=%s) - cmd=%s, curArgCount[%d]<needArgCount[%d]" % (line, cmd, len(tokens), argCount))
return 0
tokens=tokens[:argCount]
callBackFunc(*tokens)
return 1
-375
View File
@@ -1,375 +0,0 @@
import sys
import app
import dbg
import builtins
import _frozen_importlib as _bootstrap
import _frozen_importlib_external as _bootstrap_external
import marshal
import pack
import __main__
import re
# Keep import paths deterministic for the embedded runtime.
sys.path = [p for p in sys.path if isinstance(p, str)]
if "lib" not in sys.path:
sys.path.append("lib")
class TraceFile:
def write(self, msg):
dbg.Trace(msg)
def flush(self):
pass
class TraceErrorFile:
def write(self, msg):
dbg.TraceError(msg)
dbg.RegisterExceptionString(msg)
def flush(self):
pass
class LogBoxFile:
def __init__(self):
self.stderrSave = sys.stderr
self.msg = ""
def __del__(self):
self.restore()
def restore(self):
if sys:
sys.stderr = self.stderrSave
def write(self, msg):
self.msg = self.msg + msg
def show(self):
dbg.LogBox(self.msg,"Error")
sys.stdout = TraceFile()
sys.stderr = TraceErrorFile()
#
# pack file support (must move to system.py, systemrelease.pyc)
#
class pack_file_iterator(object):
def __init__(self, packfile):
self.pack_file = packfile
def __next__(self):
tmp = self.pack_file.readline()
if tmp:
return tmp
raise StopIteration
_chr = builtins.chr
_SOURCE_ENCODING_RE = re.compile(br"coding[:=]\s*([-\w.]+)")
def _extract_source_encoding(data):
for line in data.splitlines()[:2]:
match = _SOURCE_ENCODING_RE.search(line)
if not match:
continue
try:
return match.group(1).decode("ascii")
except Exception:
return None
return None
def _decode_pack_text(data):
if isinstance(data, str):
return data
if isinstance(data, bytearray):
data = bytes(data)
elif not isinstance(data, bytes):
data = bytes(data)
encodings = []
source_encoding = _extract_source_encoding(data)
if source_encoding:
encodings.append(source_encoding)
encodings.extend(("utf-8-sig", "cp949", "latin-1"))
seen = set()
for encoding in encodings:
if encoding in seen:
continue
seen.add(encoding)
try:
return data.decode(encoding)
except (LookupError, UnicodeDecodeError):
pass
return data.decode("utf-8", "replace")
class pack_file(object):
def __init__(self, filename, mode = 'rb'):
assert mode in ('r', 'rb')
if not pack.Exist(filename):
raise IOError('No file or directory')
self.mode = mode
self.data = pack.Get(filename)
if mode == 'r':
self.data = _decode_pack_text(self.data)
self.data = self.data.replace(_chr(13) + _chr(10), _chr(10)).replace(_chr(13), _chr(10))
def __iter__(self):
return pack_file_iterator(self)
def read(self, length = None):
empty = b'' if self.mode == 'rb' else ''
if not self.data:
return empty
if length:
tmp = self.data[:length]
self.data = self.data[length:]
return tmp
else:
tmp = self.data
self.data = b'' if self.mode == 'rb' else ''
return tmp
def readline(self):
newline = b'\n' if self.mode == 'rb' else _chr(10)
return self.read(self.data.find(newline)+1)
def readlines(self):
return [x for x in self]
builtins.pack_open = pack_open = pack_file
old_open = open
def open(filename, mode = 'rb'):
try:
if mode in ('r', 'rb') and pack.Exist(filename):
return pack_file(filename, mode)
except Exception:
pass
return old_open(filename, mode)
builtins.open = open
builtins.old_open = old_open
builtins.new_open = open
_ModuleType = type(sys)
module_do = lambda x:None
currentExecName = ""
class custom_import_hook(object):
def _pack_filename(self, name):
filename = name + ".py"
if pack.Exist(filename):
return filename
return None
def find_spec(self, fullname, path=None, target=None):
filename = self._pack_filename(fullname)
if not filename:
return None
return _bootstrap.spec_from_loader(fullname, self, origin=filename)
def create_module(self, spec):
return None
def exec_module(self, module):
global currentExecName
name = module.__name__
filename = self._pack_filename(name)
if not filename:
raise ImportError(name)
dbg.Trace('importing from pack %s\\n' % name)
currentExecName = name
execfile(filename, module.__dict__)
module_do(module)
def find_module(self, name, path=None):
if self._pack_filename(name):
return self
return None
def load_module(self, name):
if name in sys.modules:
return sys.modules[name]
module = _ModuleType(name)
sys.modules[name] = module
self.exec_module(module)
return sys.modules[name]
def splitext(p):
root, ext = '', ''
for c in p:
if c in ['/']:
root, ext = root + ext + c, ''
elif c == '.':
if ext:
root, ext = root + ext, c
else:
ext = c
elif ext:
ext = ext + c
else:
root = root + c
return root, ext
class PythonExecutioner:
def Run(kPESelf, sFileName, kDict):
if kPESelf.__IsCompiledFile__(sFileName):
kCode=kPESelf.__LoadCompiledFile__(sFileName)
else:
kCode=kPESelf.__LoadTextFile__(sFileName)
exec(kCode, kDict)
def __IsCompiledFile__(kPESelf, sFileName):
sBase, sExt = splitext(sFileName)
sExt=sExt.lower()
if sExt==".pyc" or sExt==".pyo":
return 1
else:
return 0
def __LoadTextFile__(kPESelf, sFileName):
sText=pack_open(sFileName,'r').read()
return compile(sText, sFileName, "exec")
def __LoadCompiledFile__(kPESelf, sFileName):
kFile=pack_open(sFileName)
magic = kFile.read(4)
if isinstance(magic, str):
magic = magic.encode("latin1")
if magic != _bootstrap_external.MAGIC_NUMBER:
raise
kFile.read(4)
kData=kFile.read()
if isinstance(kData, str):
kData = kData.encode("latin1")
return marshal.loads(kData)
def execfile(fileName, dict):
kPE=PythonExecutioner()
kPE.Run(fileName, dict)
def exec_add_module_do(mod):
global execfile
mod.__dict__['execfile'] = execfile
module_do = exec_add_module_do
meta_hook = custom_import_hook()
if meta_hook not in sys.meta_path:
sys.meta_path.insert(0, meta_hook)
"""
#
# PSYCO installation (must move to system.py, systemrelease.pyc)
#
try:
import psyco
#from psyco.classes import *
def bind_me(bindable_list):
try:
for x in bindable_list:
try:
psyco.bind(x)
except:
pass
except:
pass
_prev_psyco_old_module_do = module_do
def module_bind(module):
_prev_psyco_old_module_do(module)
#print 'start binding' + str(module)
try:
psyco.bind(module)
except:
pass
for x in module.__dict__.itervalues():
try:
psyco.bind(x)
except:
pass
#print 'end binding'
dbg.Trace("PSYCO installed\\n")
except Exception, msg:
bind_me = lambda x:None
dbg.Trace("No PSYCO support : %s\\n" % msg)
"""
def GetExceptionString(excTitle):
(excType, excMsg, excTraceBack)=sys.exc_info()
excText=""
excText+=_chr(10)
import traceback
traceLineList=traceback.extract_tb(excTraceBack)
for traceLine in traceLineList:
if traceLine[3]:
excText+="%s(line:%d) %s - %s" % (traceLine[0], traceLine[1], traceLine[2], traceLine[3])
else:
excText+="%s(line:%d) %s" % (traceLine[0], traceLine[1], traceLine[2])
excText+=_chr(10)
excText+=_chr(10)
excText+="%s - %s:%s" % (excTitle, excType, excMsg)
excText+=_chr(10)
return excText
def ShowException(excTitle):
excText=GetExceptionString(excTitle)
dbg.TraceError(excText)
app.Abort()
return 0
def RunMainScript(name):
try:
source = open(name, "rb").read()
if isinstance(source, (bytes, bytearray)):
source = _decode_pack_text(source)
exec(compile(source, name, 'exec'), __main__.__dict__)
except RuntimeError as msg:
msg = str(msg)
import locale
if locale.error:
msg = locale.error.get(msg, msg)
dbg.LogBox(msg)
app.Abort()
except:
msg = GetExceptionString("Run")
dbg.LogBox(msg)
app.Abort()
try:
import debugInfo
except ImportError:
import debuginfo as debugInfo
debugInfo.SetDebugMode(__DEBUG__)
loginMark = "-cs"
RunMainScript("prototype.py")
-51
View File
@@ -1,51 +0,0 @@
from interfaceModule import *
import app
import wndMgr
import systemSetting
import mouseModule
import grp
import ui
app.SetMouseHandler(mouseModule.mouseController)
app.SetHairColorEnable(True)
wndMgr.SetMouseHandler(mouseModule.mouseController)
wndMgr.SetScreenSize(systemSetting.GetWidth(), systemSetting.GetHeight())
app.Create("METIN2", systemSetting.GetWidth(), systemSetting.GetHeight(), 1)
mouseModule.mouseController.Create()
import chr
import uiAffectShower
class TestGame(ui.Window):
def __init__(self):
ui.Window.__init__(self)
self.affectShower = uiAffectShower.AffectShower()
self.affectShower.BINARY_NEW_AddAffect(chr.NEW_AFFECT_EXP_BONUS_EURO_FREE, 0, 100, 1000)
self.interface = Interface()
self.interface.MakeInterface()
self.interface.ShowDefaultWindows()
def __del__(self):
ui.Window.__del__(self)
def OnKeyUp(self, key):
print(key)
return True
def OnUpdate(self):
app.UpdateGame()
def OnRender(self):
app.RenderGame()
grp.PopState()
grp.SetInterfaceRenderState()
game = TestGame()
game.SetSize(systemSetting.GetWidth(), systemSetting.GetHeight())
game.Show()
app.Loop()
-3716
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
-156
View File
@@ -1,156 +0,0 @@
import dbg
import app
import player
import item
import net
import snd
import ui
import uiToolTip
import localeInfo
class AttachMetinDialog(ui.ScriptWindow):
def __init__(self):
ui.ScriptWindow.__init__(self)
self.__LoadScript()
self.metinItemPos = 0
self.targetItemPos = 0
def __LoadScript(self):
try:
pyScrLoader = ui.PythonScriptLoader()
pyScrLoader.LoadScriptFile(self, "uiscript/attachstonedialog.py")
except:
import exception
exception.Abort("AttachStoneDialog.__LoadScript.LoadObject")
try:
self.board = self.GetChild("Board")
self.titleBar = self.GetChild("TitleBar")
self.metinImage = self.GetChild("MetinImage")
self.GetChild("AcceptButton").SetEvent(ui.__mem_func__(self.Accept))
self.GetChild("CancelButton").SetEvent(ui.__mem_func__(self.Close))
except:
import exception
exception.Abort("AttachStoneDialog.__LoadScript.BindObject")
oldToolTip = uiToolTip.ItemToolTip()
oldToolTip.SetParent(self)
oldToolTip.SetPosition(15, 38)
oldToolTip.SetFollow(False)
oldToolTip.Show()
self.oldToolTip = oldToolTip
newToolTip = uiToolTip.ItemToolTip()
newToolTip.SetParent(self)
newToolTip.SetPosition(230 + 20, 38)
newToolTip.SetFollow(False)
newToolTip.Show()
self.newToolTip = newToolTip
self.titleBar.SetCloseEvent(ui.__mem_func__(self.Close))
def __del__(self):
ui.ScriptWindow.__del__(self)
def Destroy(self):
self.ClearDictionary()
self.board = 0
self.titleBar = 0
self.metinImage = 0
self.toolTip = 0
def CanAttachMetin(self, slot, metin):
if item.METIN_NORMAL == metin:
if player.METIN_SOCKET_TYPE_SILVER == slot or player.METIN_SOCKET_TYPE_GOLD == slot:
return True
elif item.METIN_GOLD == metin:
if player.METIN_SOCKET_TYPE_GOLD == slot:
return True
def Open(self, metinItemPos, targetItemPos):
self.metinItemPos = metinItemPos
self.targetItemPos = targetItemPos
metinIndex = player.GetItemIndex(metinItemPos)
itemIndex = player.GetItemIndex(targetItemPos)
self.oldToolTip.ClearToolTip()
self.newToolTip.ClearToolTip()
item.SelectItem(metinIndex)
metinSubType = item.GetItemSubType()
try:
self.metinImage.LoadImage(item.GetIconImageFileName())
except:
dbg.TraceError("AttachMetinDialog.Open.LoadImage - Failed to find item data")
# MR-12: Fix attribute and metin socket order display in tooltip
# Get actual item attributes/bonuses for display
attrSlot = []
for i in range(player.ATTRIBUTE_SLOT_MAX_NUM):
attrSlot.append(player.GetItemAttribute(targetItemPos, i))
metinSlot = []
for i in range(player.METIN_SOCKET_MAX_NUM):
metinSlot.append(player.GetItemMetinSocket(targetItemPos, i))
for i in range(player.METIN_SOCKET_MAX_NUM):
slotData = metinSlot[i]
if self.CanAttachMetin(slotData, metinSubType):
metinSlot[i] = metinIndex
break
self.newToolTip.AddItemData(itemIndex, metinSlot, attrSlot)
item.SelectItem(metinIndex)
metinSlot = []
for i in range(player.METIN_SOCKET_MAX_NUM):
metinSlot.append(player.GetItemMetinSocket(targetItemPos, i))
self.oldToolTip.ResizeToolTipWidth(self.newToolTip.GetWidth())
self.oldToolTip.AddItemData(itemIndex, metinSlot, attrSlot)
# MR-12: -- END OF -- Fix attribute and metin socket order display in tooltip
self.UpdateDialog()
self.SetTop()
self.Show()
def UpdateDialog(self):
newWidth = 15 + self.oldToolTip.GetWidth() + 45 + self.newToolTip.GetWidth() + 15
newHeight = self.newToolTip.GetHeight() + 98
self.newToolTip.SetPosition(15 + self.oldToolTip.GetWidth() + 45, 38)
if app.IsRTL():
self.board.SetPosition(newWidth, 0)
(x, y) = self.titleBar.GetLocalPosition()
self.titleBar.SetPosition(newWidth - 15, y)
self.board.SetSize(newWidth, newHeight)
self.titleBar.SetWidth(newWidth-15)
self.SetSize(newWidth, newHeight)
(x, y) = self.GetLocalPosition()
self.SetPosition(x, y)
def Accept(self):
net.SendItemUseToItemPacket(self.metinItemPos, self.targetItemPos)
snd.PlaySound("sound/ui/metinstone_insert.wav")
self.Close()
def Close(self):
self.Hide()
-149
View File
@@ -1,149 +0,0 @@
import ui
class AuctionWindow(ui.ScriptWindow):
class PageWindow(ui.ScriptWindow):
def __init__(self, parent, filename):
ui.ScriptWindow.__init__(self)
self.SetParent(parent)
self.filename = filename
def GetScriptFileName(self):
return self.filename
def __init__(self):
ui.ScriptWindow.__init__(self)
self.__LoadWindow()
self.SelectPage("UNIQUE_AUCTION")
def __LoadWindow(self):
pyScrLoader = ui.PythonScriptLoader()
pyScrLoader.LoadScriptFile(self, "uiscript/auctionwindow.py")
self.pageName = {
"LIST" : "Trade List",
"REGISTER" : "Register Trade",
"UNIQUE_AUCTION" : "Unique Auction",
}
self.pageWindow = {
"LIST" : self.PageWindow(self, "uiscript/auctionwindow_listpage.py"),
"REGISTER" : self.PageWindow(self, "uiscript/auctionwindow_registerpage.py"),
"UNIQUE_AUCTION" : self.PageWindow(self, "uiscript/auctionwindow_uniqueauctionpage.py"),
}
self.board = self.GetChild("Board")
self.tabDict = {
"LIST" : self.GetChild("Tab_01"),
"REGISTER" : self.GetChild("Tab_02"),
"UNIQUE_AUCTION" : self.GetChild("Tab_03"),
}
self.tabButtonDict = {
"LIST" : self.GetChild("Tab_Button_01"),
"REGISTER" : self.GetChild("Tab_Button_02"),
"UNIQUE_AUCTION" : self.GetChild("Tab_Button_03"),
}
for page in list(self.pageWindow.values()):
pyScrLoader.LoadScriptFile(page, page.GetScriptFileName())
for key, button in list(self.tabButtonDict.items()):
button.SetEvent(self.SelectPage, key)
self.__MakeListPage()
self.__MakeRegisterPage()
self.__MakeUniqueAuctionPage()
def Destroy(self):
self.ClearDictionary()
def __MakeListPage(self):
page = self.pageWindow["LIST"]
yPos = 27
AUCTION_LINE_COUNT = 10
for i in range(AUCTION_LINE_COUNT):
numberSlotImage = ui.MakeImageBox(page, "d:/ymir work/ui/public/Parameter_Slot_00.sub", 11, yPos)
numberSlot = ui.MakeTextLine(numberSlotImage)
page.Children.append(numberSlotImage)
page.Children.append(numberSlot)
nameSlotImage = ui.MakeImageBox(page, "d:/ymir work/ui/public/Parameter_Slot_04.sub", 55, yPos)
nameSlot = ui.MakeTextLine(nameSlotImage)
page.Children.append(nameSlotImage)
page.Children.append(nameSlot)
priceSlotImage = ui.MakeImageBox(page, "d:/ymir work/ui/public/Parameter_Slot_05.sub", 175, yPos)
priceSlot = ui.MakeTextLine(priceSlotImage)
page.Children.append(priceSlotImage)
page.Children.append(priceSlot)
deleteButton = ui.Button()
deleteButton.SetParent(page)
deleteButton.SetPosition(310, yPos)
deleteButton.SetUpVisual("d:/ymir work/ui/public/small_button_01.sub")
deleteButton.SetOverVisual("d:/ymir work/ui/public/small_button_02.sub")
deleteButton.SetDownVisual("d:/ymir work/ui/public/small_button_03.sub")
deleteButton.SetText("Purchase")
deleteButton.Show()
page.Children.append(deleteButton)
yPos += 20
def __MakeRegisterPage(self):
pass
def __MakeUniqueAuctionPage(self):
page = self.pageWindow["UNIQUE_AUCTION"]
LINE_COUNT = 3
for i in range(LINE_COUNT):
yPos = 5 + 99*i
itemSlotImage = ui.MakeSlotBar(page, 10, yPos, 97, 97)
page.Children.append(itemSlotImage)
itemName = ui.MakeTextLine(page, False, 117, yPos + 14)
page.Children.append(itemName)
## Temporary
itemName.SetText("Fairy Hairpin")
## Temporary
curPrice = ui.MakeTextLine(page, False, 117, yPos + 31)
page.Children.append(curPrice)
## Temporary
curPrice.SetText("Current Price: 2,012,341,234 Yang")
## Temporary
lastTime = ui.MakeTextLine(page, False, 117, yPos + 48)
page.Children.append(lastTime)
## Temporary
lastTime.SetText("Time Until Close: 19 min 28 sec")
## Temporary
priceSlotImage = ui.MakeImageBox(page, "d:/ymir work/ui/public/Parameter_Slot_05.sub", 117, yPos + 65)
priceSlot = ui.MakeTextLine(priceSlotImage)
page.Children.append(priceSlotImage)
page.Children.append(priceSlot)
## Temporary
priceSlot.SetText("2,012,341,234 Yang")
## Temporary
def SelectPage(self, arg):
for key, btn in list(self.tabButtonDict.items()):
if arg != key:
btn.SetUp()
for key, img in list(self.tabDict.items()):
if arg == key:
img.Show()
else:
img.Hide()
for key, page in list(self.pageWindow.items()):
if arg == key:
page.Show()
else:
page.Hide()
self.board.SetTitleName(self.pageName[arg])
-152
View File
@@ -1,152 +0,0 @@
import ui
import ime
import wndMgr
class VerticalCandidateBoard(ui.Board):
CORNER_WIDTH = 3
CORNER_HEIGHT = 3
LINE_WIDTH = 16
LINE_HEIGHT = 16
SLOT_WIDTH = 14
SLOT_HEIGHT = 14
def __init__(self):
ui.Window.__init__(self, "CURTAIN")
self.Base = None
self.BaseBar = None
self.numberList = []
self.slotList = []
def __del__(self):
ui.Board.__del__(self)
def SetCharacterCount(self, xCount, yCount):
self.SetSize(xCount*14 + 14, yCount*14 + 7)
self.BaseBar.SetSize(xCount*14 + 1, yCount*14 + 1)
self.numberList = []
self.slotList = []
for y in range(yCount):
number = ui.ImageBox()
number.SetParent(self.BaseBar)
number.LoadImage("d:/ymir work/ui/pattern/ime/%d.tga" % (y+1))
number.SetPosition(5 - 10, 8 + y * 14 - 3)
number.Show()
self.numberList.append(number)
slot = ui.Bar()
slot.SetParent(self.BaseBar)
slot.SetPosition(10 + 1 - 10, 3 + y*14 + 1 - 3)
slot.SetSize(xCount*14 - 1, 13)
slot.SetColor(0xFF302C2A)
slot.Show()
self.slotList.append(slot)
#################################################################
def SetCandidatePosition(self, x, y, textCount):
xPos = x + (textCount - 5) * 6 + 2
yPos = y - self.GetHeight() - 2
self.SetPosition(xPos, yPos)
def Load(self):
self.MakeBoard("d:/ymir work/ui/pattern/ime/corner_", "d:/ymir work/ui/pattern/ime/bar_")
BaseBar = ui.Bar()
BaseBar.SetParent(self)
BaseBar.SetPosition(10, 3)
BaseBar.SetColor(0xff000000)
BaseBar.Show()
self.BaseBar = BaseBar
candidateListBox = ui.CandidateListBox(ui.CandidateListBox.VERTICAL_MODE)
candidateListBox.SetParent(self)
candidateListBox.SetPosition(11, 4)
candidateListBox.SetItemSize(16, 14)
candidateListBox.SetItemStep(14)
candidateListBox.Show()
self.candidateListBox = candidateListBox
def Clear(self):
self.candidateListBox.RemoveAllItems()
def Append(self, text):
self.candidateListBox.AppendItem(ui.CandidateListBox.Item(text))
def Refresh(self):
maxTextLength = 0
yCount = ime.GetCandidateCount()
for i in range(yCount):
text, length = ime.GetCandidate(i)
self.Append(text)
if length > maxTextLength:
maxTextLength = length
if maxTextLength > 0:
self.SetCharacterCount(maxTextLength, yCount)
self.candidateListBox.SelectIndex(ime.GetCandidateSelection())
class KORCandidateWindow(ui.ScriptWindow):
def __init__(self):
ui.Window.__init__(self, "CURTAIN")
self.candidateListBox=None
def __del__(self):
ui.Window.__del__(self)
def SetCandidatePosition(self, x, y, textCount):
xPos = x + textCount*6 - 20
yPos = y + 20
xPos = min(xPos, wndMgr.GetScreenWidth() - self.GetWidth())
self.SetPosition(xPos, yPos)
def Clear(self):
self.candidateListBox.RemoveAllItems()
def Append(self, text):
self.candidateListBox.AppendItem(ui.CandidateListBox.Item(text))
def Refresh(self):
for i in range(9):
text, length = ime.GetCandidate(i)
self.Append(text)
self.candidateListBox.SelectIndex(ime.GetCandidateSelection())
def Select(self, pos):
self.candidateListBox.SelectIndex(pos)
def Load(self):
self.__LoadScript()
self.__BindObject()
def __LoadScript(self):
try:
pyScrLoader = ui.PythonScriptLoader()
pyScrLoader.LoadScriptFile(self, "UIScript/IMEKOR.py")
except:
import exception
exception.Abort("CandidateWindow.__LoadScript")
def __BindObject(self):
try:
self.candidateListBox=self.GetChild("CandidateList")
except:
import exception
exception.Abort("CandidateWindow.__BindObject")
ui.RegisterCandidateWindowClass(KORCandidateWindow)
ui.RegisterCandidateWindowClass(VerticalCandidateBoard)
ui.RegisterCandidateWindowClass(VerticalCandidateBoard)
ui.RegisterCandidateWindowClass(VerticalCandidateBoard)
File diff suppressed because it is too large Load Diff
-1173
View File
File diff suppressed because it is too large Load Diff
-472
View File
@@ -1,472 +0,0 @@
import ui
import localeInfo
import app
import ime
import uiScriptLocale
class PopupDialog(ui.ScriptWindow):
def __init__(self):
ui.ScriptWindow.__init__(self)
self.__LoadDialog()
self.acceptEvent = lambda *arg: None
def __del__(self):
ui.ScriptWindow.__del__(self)
def __LoadDialog(self):
try:
PythonScriptLoader = ui.PythonScriptLoader()
PythonScriptLoader.LoadScriptFile(self, "UIScript/PopupDialog.py")
self.board = self.GetChild("board")
self.message = self.GetChild("message")
self.accceptButton = self.GetChild("accept")
self.accceptButton.SetEvent(ui.__mem_func__(self.Close))
except:
import exception
exception.Abort("PopupDialog.LoadDialog.BindObject")
def Open(self):
self.SetCenterPosition()
self.SetTop()
self.Show()
def Close(self):
self.Hide()
self.acceptEvent()
def Destroy(self):
self.Close()
self.ClearDictionary()
def SetWidth(self, width):
height = self.GetHeight()
self.SetSize(width, height)
self.board.SetSize(width, height)
self.SetCenterPosition()
self.UpdateRect()
def SetText(self, text):
self.message.SetText(text)
def SetAcceptEvent(self, event):
self.acceptEvent = event
def SetButtonName(self, name):
self.accceptButton.SetText(name)
def OnPressEscapeKey(self):
self.Close()
return True
def OnIMEReturn(self):
self.Close()
return True
class InputDialog(ui.ScriptWindow):
def __init__(self):
ui.ScriptWindow.__init__(self)
self.__CreateDialog()
def __del__(self):
ui.ScriptWindow.__del__(self)
def __CreateDialog(self):
pyScrLoader = ui.PythonScriptLoader()
pyScrLoader.LoadScriptFile(self, "uiscript/inputdialog.py")
getObject = self.GetChild
self.board = getObject("Board")
self.acceptButton = getObject("AcceptButton")
self.cancelButton = getObject("CancelButton")
self.inputSlot = getObject("InputSlot")
self.inputValue = getObject("InputValue")
def Open(self):
self.inputValue.SetFocus()
self.SetCenterPosition()
self.SetTop()
self.Show()
def Close(self):
self.ClearDictionary()
self.board = None
self.acceptButton = None
self.cancelButton = None
self.inputSlot = None
self.inputValue = None
self.Hide()
def SetTitle(self, name):
self.board.SetTitleName(name)
def SetNumberMode(self):
self.inputValue.SetNumberMode()
def SetSecretMode(self):
self.inputValue.SetSecret()
def SetFocus(self):
self.inputValue.SetFocus()
def SetMaxLength(self, length):
width = length * 6 + 10
self.SetBoardWidth(max(width + 50, 160))
self.SetSlotWidth(width)
self.inputValue.SetMax(length)
def SetSlotWidth(self, width):
self.inputSlot.SetSize(width, self.inputSlot.GetHeight())
self.inputValue.SetSize(width, self.inputValue.GetHeight())
if self.IsRTL():
self.inputValue.SetPosition(self.inputValue.GetWidth(), 0)
def SetBoardWidth(self, width):
self.SetSize(max(width + 50, 160), self.GetHeight())
self.board.SetSize(max(width + 50, 160), self.GetHeight())
if self.IsRTL():
self.board.SetPosition(self.board.GetWidth(), 0)
self.UpdateRect()
def SetAcceptEvent(self, event):
self.acceptButton.SetEvent(event)
self.inputValue.OnIMEReturn = event
def SetCancelEvent(self, event):
self.board.SetCloseEvent(event)
self.cancelButton.SetEvent(event)
self.inputValue.OnPressEscapeKey = event
def GetText(self):
return self.inputValue.GetText()
class InputDialogWithDescription(InputDialog):
def __init__(self):
ui.ScriptWindow.__init__(self)
self.__CreateDialog()
def __del__(self):
InputDialog.__del__(self)
def __CreateDialog(self):
pyScrLoader = ui.PythonScriptLoader()
if app.IsRTL() :
pyScrLoader.LoadScriptFile(self, uiScriptLocale.LOCALE_UISCRIPT_PATH + "inputdialogwithdescription.py")
else:
pyScrLoader.LoadScriptFile(self, "uiscript/inputdialogwithdescription.py")
try:
getObject = self.GetChild
self.board = getObject("Board")
self.acceptButton = getObject("AcceptButton")
self.cancelButton = getObject("CancelButton")
self.inputSlot = getObject("InputSlot")
self.inputValue = getObject("InputValue")
self.description = getObject("Description")
except:
import exception
exception.Abort("InputDialogWithDescription.LoadBoardDialog.BindObject")
def SetDescription(self, text):
self.description.SetText(text)
class InputDialogWithDescription2(InputDialog):
def __init__(self):
ui.ScriptWindow.__init__(self)
self.__CreateDialog()
def __del__(self):
InputDialog.__del__(self)
def __CreateDialog(self):
pyScrLoader = ui.PythonScriptLoader()
pyScrLoader.LoadScriptFile(self, "uiscript/inputdialogwithdescription2.py")
try:
getObject = self.GetChild
self.board = getObject("Board")
self.acceptButton = getObject("AcceptButton")
self.cancelButton = getObject("CancelButton")
self.inputSlot = getObject("InputSlot")
self.inputValue = getObject("InputValue")
self.description1 = getObject("Description1")
self.description2 = getObject("Description2")
except:
import exception
exception.Abort("InputDialogWithDescription.LoadBoardDialog.BindObject")
def SetDescription1(self, text):
self.description1.SetText(text)
def SetDescription2(self, text):
self.description2.SetText(text)
class QuestionDialog(ui.ScriptWindow):
# MR-15: Multiline dialog messages
BASE_HEIGHT = 105
BASE_WIDTH = 340
BUTTON_Y = 63
LINE_HEIGHT = 12
# MR-15: -- END OF -- Multiline dialog messages
def __init__(self):
ui.ScriptWindow.__init__(self)
self.__CreateDialog()
def __del__(self):
ui.ScriptWindow.__del__(self)
def __CreateDialog(self):
pyScrLoader = ui.PythonScriptLoader()
pyScrLoader.LoadScriptFile(self, "uiscript/questiondialog.py")
self.board = self.GetChild("board")
self.textLine = self.GetChild("message")
self.acceptButton = self.GetChild("accept")
self.cancelButton = self.GetChild("cancel")
def Open(self):
self.SetCenterPosition()
self.SetTop()
self.Show()
def Close(self):
self.Hide()
def SetWidth(self, width):
height = self.GetHeight()
self.SetSize(width, height)
self.board.SetSize(width, height)
self.SetCenterPosition()
self.UpdateRect()
def SAFE_SetAcceptEvent(self, event):
self.acceptButton.SAFE_SetEvent(event)
def SAFE_SetCancelEvent(self, event):
self.cancelButton.SAFE_SetEvent(event)
def SetAcceptEvent(self, event):
self.acceptButton.SetEvent(event)
def SetCancelEvent(self, event):
self.cancelButton.SetEvent(event)
def SetText(self, text):
self.textLine.SetText(text)
# MR-15: Multiline dialog messages
self.__UpdateLayout()
# MR-15: -- END OF -- Multiline dialog messages
def SetAcceptText(self, text):
self.acceptButton.SetText(text)
def SetCancelText(self, text):
self.cancelButton.SetText(text)
# MR-15: Multiline dialog messages
def __UpdateLayout(self):
extraH = len(self.textLine.extraLines) * self.LINE_HEIGHT
newH = self.BASE_HEIGHT + extraH + 10
btnY = self.BUTTON_Y + extraH + 10
self.SetSize(self.BASE_WIDTH, newH)
self.board.SetSize(self.BASE_WIDTH, newH)
self.acceptButton.SetPosition(-40, btnY)
self.cancelButton.SetPosition(+40, btnY)
self.SetCenterPosition()
self.UpdateRect()
# MR-15: -- END OF -- Multiline dialog messages
def OnPressEscapeKey(self):
self.Close()
return True
class QuestionDialog2(QuestionDialog):
# MR-15: Multiline dialog messages
BASE_HEIGHT = 105
BUTTON_Y = 68
LINE_HEIGHT = 12
# MR-15: -- END OF -- Multiline dialog messages
def __init__(self):
QuestionDialog.__init__(self)
self.__CreateDialog()
def __del__(self):
QuestionDialog.__del__(self)
def __CreateDialog(self):
pyScrLoader = ui.PythonScriptLoader()
pyScrLoader.LoadScriptFile(self, "uiscript/questiondialog2.py")
self.board = self.GetChild("board")
self.textLine1 = self.GetChild("message1")
self.textLine2 = self.GetChild("message2")
self.acceptButton = self.GetChild("accept")
self.cancelButton = self.GetChild("cancel")
# MR-15: Multiline dialog messages
def SetText1(self, text):
self.textLine1.SetText(text)
self.__UpdateLayout()
def SetText2(self, text):
self.textLine2.SetText(text)
self.__UpdateLayout()
def __UpdateLayout(self):
# Shift textLine2 down by the number of extra lines in textLine1
offset = len(self.textLine1.extraLines) * self.LINE_HEIGHT + 2
try:
x2, y2 = self.textLine2.GetLocalPosition()
self.textLine2.SetPosition(x2, y2 + offset)
except:
pass
extraH = (len(self.textLine1.extraLines) + len(self.textLine2.extraLines)) * self.LINE_HEIGHT
newH = self.BASE_HEIGHT + extraH + 10
btnY = self.BUTTON_Y + extraH + 10
self.SetSize(280, newH)
self.board.SetSize(280, newH)
self.acceptButton.SetPosition(-40, btnY)
self.cancelButton.SetPosition(+40, btnY)
self.SetCenterPosition()
self.UpdateRect()
# MR-15: -- END OF -- Multiline dialog messages
class QuestionDialogWithTimeLimit(QuestionDialog2):
def __init__(self):
ui.ScriptWindow.__init__(self)
self.__CreateDialog()
self.endTime = 0
def __del__(self):
QuestionDialog2.__del__(self)
def __CreateDialog(self):
pyScrLoader = ui.PythonScriptLoader()
pyScrLoader.LoadScriptFile(self, "uiscript/questiondialog2.py")
self.board = self.GetChild("board")
self.textLine1 = self.GetChild("message1")
self.textLine2 = self.GetChild("message2")
self.acceptButton = self.GetChild("accept")
self.cancelButton = self.GetChild("cancel")
def Open(self, msg, timeout):
self.SetCenterPosition()
self.SetTop()
self.Show()
self.SetText1(msg)
self.endTime = app.GetTime() + timeout
def OnUpdate(self):
leftTime = max(0, self.endTime - app.GetTime())
self.SetText2(localeInfo.UI_LEFT_TIME % (leftTime))
class MoneyInputDialog(ui.ScriptWindow):
def __init__(self):
ui.ScriptWindow.__init__(self)
self.moneyHeaderText = localeInfo.MONEY_INPUT_DIALOG_SELLPRICE
self.__CreateDialog()
self.SetMaxLength(9)
def __del__(self):
ui.ScriptWindow.__del__(self)
def __CreateDialog(self):
pyScrLoader = ui.PythonScriptLoader()
pyScrLoader.LoadScriptFile(self, "uiscript/moneyinputdialog.py")
getObject = self.GetChild
self.board = self.GetChild("board")
self.acceptButton = getObject("AcceptButton")
self.cancelButton = getObject("CancelButton")
self.inputValue = getObject("InputValue")
self.inputValue.SetNumberMode()
self.inputValue.OnIMEUpdate = ui.__mem_func__(self.__OnValueUpdate)
self.moneyText = getObject("MoneyValue")
def Open(self):
self.inputValue.SetText("")
self.inputValue.SetFocus()
self.__OnValueUpdate()
self.SetCenterPosition()
self.SetTop()
self.Show()
def Close(self):
self.ClearDictionary()
self.board = None
self.acceptButton = None
self.cancelButton = None
self.inputValue = None
self.Hide()
def SetTitle(self, name):
self.board.SetTitleName(name)
def SetFocus(self):
self.inputValue.SetFocus()
def SetMaxLength(self, length):
length = min(9, length)
self.inputValue.SetMax(length)
def SetMoneyHeaderText(self, text):
self.moneyHeaderText = text
def SetAcceptEvent(self, event):
self.acceptButton.SetEvent(event)
self.inputValue.OnIMEReturn = event
def SetCancelEvent(self, event):
self.board.SetCloseEvent(event)
self.cancelButton.SetEvent(event)
self.inputValue.OnPressEscapeKey = event
def SetValue(self, value):
value=str(value)
self.inputValue.SetText(value)
self.__OnValueUpdate()
ime.SetCursorPosition(len(value))
def GetText(self):
return self.inputValue.GetText()
def __OnValueUpdate(self):
ui.EditLine.OnIMEUpdate(self.inputValue)
text = self.inputValue.GetText()
money = 0
if text and text.isdigit():
try:
money = int(text)
except ValueError:
money = 199999999
self.moneyText.SetText(self.moneyHeaderText + localeInfo.NumberToMoneyString(money))
-601
View File
@@ -1,601 +0,0 @@
import ui
import app
import net
import mouseModule
import player
import snd
import localeInfo
import item
import grp
import uiScriptLocale
import uiToolTip
class CubeResultWindow(ui.ScriptWindow):
def __init__(self):
ui.ScriptWindow.__init__(self)
def __del__(self):
ui.ScriptWindow.__del__(self)
def LoadWindow(self):
try:
pyScrLoader = ui.PythonScriptLoader()
pyScrLoader.LoadScriptFile(self, "UIScript/CubeResultWindow.py")
except:
import exception
exception.Abort("CubeResultWindow.LoadDialog.LoadScript")
try:
GetObject=self.GetChild
self.titleBar = GetObject("TitleBar")
self.btnClose = GetObject("CloseButton")
self.cubeSlot = GetObject("CubeSlot")
except:
import exception
exception.Abort("CubeWindow.LoadDialog.BindObject")
self.cubeSlot.SetOverInItemEvent(ui.__mem_func__(self.__OnOverInItem))
self.cubeSlot.SetOverOutItemEvent(ui.__mem_func__(self.__OnOverOutItem))
self.titleBar.SetCloseEvent(ui.__mem_func__(self.__OnCloseButtonClick))
self.btnClose.SetEvent(ui.__mem_func__(self.__OnCloseButtonClick))
self.itemVnum = 0
def Destroy(self):
self.ClearDictionary()
self.titleBar = None
self.btnClose = None
self.cubeSlot = None
self.tooltipItem = None
self.itemVnum = 0
def SetItemToolTip(self, tooltipItem):
self.tooltipItem = tooltipItem
def SetCubeResultItem(self, itemVnum, count):
self.itemVnum = itemVnum
if 0 == count:
count = 1
self.cubeSlot.SetItemSlot(0, itemVnum, count)
def Open(self):
self.Show()
def Close(self):
self.Hide()
def __OnCloseButtonClick(self):
self.Close()
def __OnOverInItem(self, slotIndex):
if self.tooltipItem:
if 0 != self.itemVnum:
self.tooltipItem.SetItemToolTip(self.itemVnum)
def __OnOverOutItem(self):
if self.tooltipItem:
self.tooltipItem.HideToolTip()
def OnPressEscapeKey(self):
if 0 != self.eventClose:
self.eventClose()
return True
class CubeWindow(ui.ScriptWindow):
def __init__(self):
ui.ScriptWindow.__init__(self)
self.xShopStart = 0
self.yShopStart = 0
self.isUsable = False
def __del__(self):
ui.ScriptWindow.__del__(self)
def LoadWindow(self):
try:
pyScrLoader = ui.PythonScriptLoader()
pyScrLoader.LoadScriptFile(self, "UIScript/CubeWindow.py")
except:
import exception
exception.Abort("CubeWindow.LoadDialog.LoadScript")
try:
GetObject=self.GetChild
if app.IsRTL():
self.board = GetObject("board")
self.board.SetScale(-1.0, 1.0)
self.board.SetRenderingRect(-1.0, 0.0, 1.0, 0.0)
self.titleBar = GetObject("TitleBar")
self.btnAccept = GetObject("AcceptButton")
self.btnCancel = GetObject("CancelButton")
self.cubeSlot = GetObject("CubeSlot")
self.needMoney = GetObject("NeedMoney")
self.contentScrollbar = GetObject("contentScrollbar")
self.resultSlots = [GetObject("result1"), GetObject("result2"), GetObject("result3")]
self.materialSlots = [
[GetObject("material11"), GetObject("material12"), GetObject("material13"), GetObject("material14"), GetObject("material15")],
[GetObject("material21"), GetObject("material22"), GetObject("material23"), GetObject("material24"), GetObject("material25")],
[GetObject("material31"), GetObject("material32"), GetObject("material33"), GetObject("material34"), GetObject("material35")],
]
row = 0
for materialRow in self.materialSlots:
j = 0
for material in materialRow:
material.SetOverInItemEvent(lambda trash = 0, rowIndex = row, col = j: self.__OverInMaterialSlot(trash, rowIndex, col))
material.SetSelectItemSlotEvent(lambda trash = 0, rowIndex = row, col = j: self.__OnSelectMaterialSlot(trash, rowIndex, col))
material.SetOverOutItemEvent(lambda : self.__OverOutMaterialSlot())
j = j + 1
row = row + 1
row = 0
for resultSlot in self.resultSlots:
resultSlot.SetOverInItemEvent(lambda trash = 0, rowIndex = row: self.__OverInCubeResultSlot(trash, rowIndex))
resultSlot.SetOverOutItemEvent(lambda : self.__OverOutMaterialSlot())
row = row + 1
except:
import exception
exception.Abort("CubeWindow.LoadDialog.BindObject")
self.contentScrollbar.SetScrollStep(0.15)
self.contentScrollbar.SetScrollEvent(ui.__mem_func__(self.OnScrollResultList))
self.cubeSlot.SetSelectEmptySlotEvent(ui.__mem_func__(self.__OnSelectEmptySlot))
self.cubeSlot.SetSelectItemSlotEvent(ui.__mem_func__(self.__OnSelectItemSlot))
self.cubeSlot.SetOverInItemEvent(ui.__mem_func__(self.__OnOverInItem))
self.cubeSlot.SetOverOutItemEvent(ui.__mem_func__(self.__OnOverOutItem))
self.titleBar.SetCloseEvent(ui.__mem_func__(self.__OnCloseButtonClick))
self.btnCancel.SetEvent(ui.__mem_func__(self.__OnCloseButtonClick))
self.btnAccept.SetEvent(ui.__mem_func__(self.__OnAcceptButtonClick))
self.cubeItemInfo = {}
self.cubeResultInfos = []
self.cubeMaterialInfos = {}
self.tooltipItem = None
self.firstSlotIndex = 0
self.RESULT_SLOT_COUNT = len(self.resultSlots)
self.SLOT_SIZEX = 32
self.SLOT_SIZEY = 32
self.CUBE_SLOT_COUNTX = 8
self.CUBE_SLOT_COUNTY = 3
def SetItemToolTip(self, itemTooltip):
self.tooltipItem = itemTooltip
def GetResultCount(self):
return len(self.cubeResultInfos)
def OnScrollResultList(self):
count = self.GetResultCount()
scrollLineCount = max(0, count - self.RESULT_SLOT_COUNT)
startIndex = int(scrollLineCount * self.contentScrollbar.GetPos())
if startIndex != self.firstSlotIndex:
self.firstSlotIndex = startIndex
self.Refresh()
def AddCubeResultItem(self, itemVnum, count):
self.cubeResultInfos.append((itemVnum, count))
#self.Refresh()
def AddMaterialInfo(self, itemIndex, orderIndex, itemVnum, itemCount):
if itemIndex not in self.cubeMaterialInfos:
self.cubeMaterialInfos[itemIndex] = [[], [], [], [], []]
self.cubeMaterialInfos[itemIndex][orderIndex].append((itemVnum, itemCount))
#print "AddMaterialInfo", itemIndex, orderIndex, itemVnum, itemCount, self.cubeMaterialInfos
def ClearCubeResultItem(self):
self.cubeResultInfos = []
self.Refresh()
def Destroy(self):
self.ClearDictionary()
self.titleBar = None
self.btnAccept = None
self.btnCancel = None
self.cubeSlot = None
self.tooltipItem = None
self.needMoney = None
def __OverOutMaterialSlot(self):
self.tooltipItem.SetCannotUseItemForceSetDisableColor(True)
self.tooltipItem.HideToolTip()
def __OverInCubeResultSlot(self, trash, resultIndex):
self.tooltipItem.ClearToolTip()
self.tooltipItem.SetCannotUseItemForceSetDisableColor(True)
metinSlot = []
for i in range(player.METIN_SOCKET_MAX_NUM):
metinSlot.append(0)
attrSlot = []
for i in range(player.ATTRIBUTE_SLOT_MAX_NUM):
attrSlot.append((0, 0))
#print "resultIndex, firstSlotIndex", resultIndex, self.firstSlotIndex
resultIndex = resultIndex + self.firstSlotIndex
itemVnum, itemCount = self.cubeResultInfos[resultIndex]
self.tooltipItem.AddItemData(itemVnum, metinSlot, attrSlot)
# Click material to find and register item from inventory.
def __OnSelectMaterialSlot(self, trash, resultIndex, materialIndex):
resultIndex = resultIndex + self.firstSlotIndex
if resultIndex not in self.cubeMaterialInfos:
return
materialInfo = self.cubeMaterialInfos[resultIndex]
materialCount = len(materialInfo[materialIndex])
if 0 == materialCount:
return
for itemVnum, itemCount in materialInfo[materialIndex]:
bAddedNow = False # Was item added by this click?
item.SelectItem(itemVnum)
itemSizeX, itemSizeY = item.GetItemSize()
# Do you have enough materials for crafting?
if player.GetItemCountByVnum(itemVnum) >= itemCount:
for i in range(player.INVENTORY_SLOT_COUNT):
vnum = player.GetItemIndex(i)
count= player.GetItemCount(i)
if vnum == itemVnum and count >= itemCount:
# Check if same item already registered, add if not
bAlreadyExists = False
for slotPos, invenPos in list(self.cubeItemInfo.items()):
if invenPos == i:
bAlreadyExists = True
if True == bAlreadyExists:
continue #continue inventory iterating
#print "Cube Status : ", self.cubeItemInfo
# If entered here, item not registered in cube, so add to empty cube slot
bCanAddSlot = False
for slotPos in range(self.cubeSlot.GetSlotCount()):
# Is this cube slot empty?
if not slotPos in self.cubeItemInfo:
upperColumnItemSizeY = -1
currentSlotLine = int(slotPos / self.CUBE_SLOT_COUNTX)
cubeColumn = int(slotPos % self.CUBE_SLOT_COUNTX)
# If 3-slot item registered in cube, skip this column entirely
if cubeColumn in self.cubeItemInfo:
columnVNUM = player.GetItemIndex(self.cubeItemInfo[cubeColumn])
item.SelectItem(columnVNUM)
columnItemSizeX, columnItemSizeY = item.GetItemSize()
if 3 == columnItemSizeY:
continue #continue cube slot iterating
if 0 < currentSlotLine and slotPos - self.CUBE_SLOT_COUNTX in self.cubeItemInfo:
upperColumnVNUM = player.GetItemIndex(self.cubeItemInfo[slotPos - self.CUBE_SLOT_COUNTX])
item.SelectItem(upperColumnVNUM)
columnItemSizeX, upperColumnItemSizeY = item.GetItemSize()
# 1-slot items must have 1-slot item directly above
if 1 == itemSizeY:
if 0 == currentSlotLine:
bCanAddSlot = True
elif 1 == currentSlotLine and 1 == upperColumnItemSizeY:
bCanAddSlot = True
elif 2 == currentSlotLine:
bCanAddSlot = True
# 2-slot items must have empty spaces above and below
elif 2 == itemSizeY:
if 0 == currentSlotLine and not cubeColumn + self.CUBE_SLOT_COUNTX in self.cubeItemInfo:
bCanAddSlot = True
elif 1 == currentSlotLine and 1 == upperColumnItemSizeY and not cubeColumn + (self.CUBE_SLOT_COUNTX * 2) in self.cubeItemInfo:
bCanAddSlot = True
# 3-slot items require entire column to be empty
else:
if not cubeColumn in self.cubeItemInfo and not cubeColumn + self.CUBE_SLOT_COUNTX in self.cubeItemInfo and not cubeColumn + (self.CUBE_SLOT_COUNTX * 2) in self.cubeItemInfo:
bCanAddSlot = True
if True == bCanAddSlot:
self.cubeItemInfo[slotPos] = i
self.cubeSlot.SetItemSlot(slotPos, vnum, count)
net.SendChatPacket("/cube add %d %d" % (slotPos, i))
bAddedNow = True
if True == bAddedNow:
break #break cube slot iterating
if True == bAddedNow:
break #break inventory iterating
if True == bAddedNow:
break #break material iterating
def __OverInMaterialSlot(self, trash, resultIndex, col):
self.tooltipItem.ClearToolTip()
self.tooltipItem.SetCannotUseItemForceSetDisableColor(False)
resultIndex = resultIndex + self.firstSlotIndex
if resultIndex not in self.cubeMaterialInfos:
return
i = 0
materialInfo = self.cubeMaterialInfos[resultIndex]
materialCount = len(materialInfo[col])
for itemVnum, count in materialInfo[col]:
item.SelectItem(itemVnum)
if player.GetItemCountByVnum(itemVnum) >= count:
self.tooltipItem.AppendTextLine("%s" % (item.GetItemName()), grp.GenerateColor(0.5411, 0.7254, 0.5568, 1.0)).SetFeather()
else:
self.tooltipItem.AppendTextLine("%s" % (item.GetItemName()), grp.GenerateColor(0.9, 0.4745, 0.4627, 1.0)).SetFeather()
if i < materialCount - 1:
self.tooltipItem.AppendTextLine(uiScriptLocale.CUBE_REQUIRE_MATERIAL_OR)
i = i + 1
self.tooltipItem.Show()
def Open(self):
self.cubeItemInfo = {}
self.cubeResultInfos = []
self.cubeMaterialInfos = {}
self.Refresh()
self.Show()
self.isUsable = True
(self.xShopStart, self.yShopStart, z) = player.GetMainCharacterPosition()
def UpdateInfo(self, gold, itemVnum, count):
if self.needMoney:
self.needMoney.SetText(localeInfo.NumberToMoneyString(gold))
self.Refresh()
def OnPressEscapeKey(self):
self.__OnCloseButtonClick()
return True
def Close(self):
if self.tooltipItem:
self.tooltipItem.HideToolTip()
self.Hide()
self.cubeItemInfo = {}
self.cubeMaterialInfos = {}
self.cubeResultInfos = {}
self.firstSlotIndex = 0
self.contentScrollbar.SetPos(0)
if self.needMoney:
self.needMoney.SetText("0")
def Clear(self):
self.Refresh()
def Refresh(self):
for slotPos in range(self.cubeSlot.GetSlotCount()):
if not slotPos in self.cubeItemInfo:
self.cubeSlot.ClearSlot(slotPos)
continue
invenPos = self.cubeItemInfo[slotPos]
itemCount = player.GetItemCount(invenPos)
if itemCount > 0:
self.cubeSlot.SetItemSlot(slotPos, player.GetItemIndex(invenPos), itemCount)
else:
del self.cubeItemInfo[slotPos]
self.cubeSlot.ClearSlot(slotPos)
i = 0
for itemVnum, count in self.cubeResultInfos[self.firstSlotIndex:]:
currentSlot = self.resultSlots[i]
item.SelectItem(itemVnum)
currentSlot.SetItemSlot(0, itemVnum, count)
currentSlot.Show()
# Center Align
item.SelectItem(itemVnum)
sizeX, sizeY = item.GetItemSize()
localX, localY = currentSlot.GetLocalPosition()
currentSlot.SetSize(self.SLOT_SIZEX, self.SLOT_SIZEY * sizeY)
adjustLocalY = 0
if sizeY < 3:
adjustLocalY = int(32 / sizeY)
currentSlot.SetPosition(localX, 0 + adjustLocalY)
i = i + 1
if 3 <= i:
break
#print "self.cubeMaterialInfos : ", self.cubeMaterialInfos
if self.firstSlotIndex in self.cubeMaterialInfos:
for i in range(self.RESULT_SLOT_COUNT):
materialList = self.cubeMaterialInfos[self.firstSlotIndex + i]
#print "Refresh ::: ", materialList
j = 0
for materialInfo in materialList:
if 0 < len(materialInfo):
currentSlot = self.materialSlots[i][j]
itemVnum, itemCount = materialInfo[0]
currentSlot.SetItemSlot(0, itemVnum, itemCount)
j = j + 1
# Center Align
item.SelectItem(itemVnum)
sizeX, sizeY = item.GetItemSize()
localX, localY = currentSlot.GetLocalPosition()
currentSlot.SetSize(self.SLOT_SIZEX, self.SLOT_SIZEY * sizeY)
adjustLocalY = 0
if sizeY < 3:
adjustLocalY = int(32 / sizeY)
currentSlot.SetPosition(localX, 0 + adjustLocalY)
for k in range(5):
if k >= j:
self.materialSlots[i][k].ClearSlot(0)
if self.RESULT_SLOT_COUNT <= i:
break
self.cubeSlot.RefreshSlot()
def __OnCloseButtonClick(self):
if self.isUsable:
self.isUsable = False
print("Close cube")
net.SendChatPacket("/cube close")
self.Close()
def __OnAcceptButtonClick(self):
if len(self.cubeItemInfo) == 0:
"Empty cube"
return
print("Start cube crafting")
#for invenPos in self.cubeItemInfo.values():
# net.SendChatPacket("/cube add " + str(invenPos))
net.SendChatPacket("/cube make")
def __OnSelectEmptySlot(self, selectedSlotPos):
isAttached = mouseModule.mouseController.isAttached()
if isAttached:
attachedSlotType = mouseModule.mouseController.GetAttachedType()
attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
mouseModule.mouseController.DeattachObject()
if player.SLOT_TYPE_INVENTORY != attachedSlotType:
return
for slotPos, invenPos in list(self.cubeItemInfo.items()):
if invenPos == attachedSlotPos:
del self.cubeItemInfo[slotPos]
self.cubeItemInfo[selectedSlotPos] = attachedSlotPos
net.SendChatPacket("/cube add %d %d" % (selectedSlotPos, attachedSlotPos))
self.Refresh()
def __OnSelectItemSlot(self, selectedSlotPos):
isAttached = mouseModule.mouseController.isAttached()
if isAttached:
snd.PlaySound("sound/ui/loginfail.wav")
mouseModule.mouseController.DeattachObject()
else:
if not selectedSlotPos in self.cubeItemInfo:
return
snd.PlaySound("sound/ui/drop.wav")
net.SendChatPacket("/cube del %d " % selectedSlotPos)
del self.cubeItemInfo[selectedSlotPos]
self.Refresh()
def __OnOverInItem(self, slotIndex):
if self.tooltipItem:
if slotIndex in self.cubeItemInfo:
self.tooltipItem.SetInventoryItem(self.cubeItemInfo[slotIndex])
def __OnOverOutItem(self):
if self.tooltipItem:
self.tooltipItem.HideToolTip()
def OnUpdate(self):
USE_SHOP_LIMIT_RANGE = 1000
(x, y, z) = player.GetMainCharacterPosition()
if abs(x - self.xShopStart) > USE_SHOP_LIMIT_RANGE or abs(y - self.yShopStart) > USE_SHOP_LIMIT_RANGE:
self.__OnCloseButtonClick()
if __name__ == "__main__":
import app
import wndMgr
import systemSetting
import mouseModule
import grp
import ui
import uiToolTip
import localeInfo
app.SetMouseHandler(mouseModule.mouseController)
app.SetHairColorEnable(True)
wndMgr.SetMouseHandler(mouseModule.mouseController)
wndMgr.SetScreenSize(systemSetting.GetWidth(), systemSetting.GetHeight())
app.Create(localeInfo.APP_TITLE, systemSetting.GetWidth(), systemSetting.GetHeight(), 1)
mouseModule.mouseController.Create()
class TestGame(ui.Window):
def __init__(self):
ui.Window.__init__(self)
localeInfo.LoadLocaleData()
self.tooltipItem = uiToolTip.ItemToolTip()
self.tooltipItem.Hide()
self.cubeWindow = CubeWindow()
self.cubeWindow.LoadWindow()
self.cubeWindow.SetItemToolTip(self.tooltipItem)
self.cubeWindow.Open()
self.cubeResultWindow = CubeResultWindow()
self.cubeResultWindow.LoadWindow()
self.cubeResultWindow.SetItemToolTip(self.tooltipItem)
self.cubeResultWindow.SetCubeResultItem(27001, 1)
self.cubeResultWindow.Open()
def __del__(self):
ui.Window.__del__(self)
def OnUpdate(self):
app.UpdateGame()
def OnRender(self):
app.RenderGame()
grp.PopState()
grp.SetInterfaceRenderState()
game = TestGame()
game.SetSize(systemSetting.GetWidth(), systemSetting.GetHeight())
game.Show()
app.Loop()
File diff suppressed because it is too large Load Diff
-124
View File
@@ -1,124 +0,0 @@
import ui
import chr
import player
class EquipmentDialog(ui.ScriptWindow):
def __init__(self):
print("NEW EQUIPMENT DIALOG ----------------------------------------------------------------------------")
ui.ScriptWindow.__init__(self)
self.__LoadDialog()
self.vid = None
self.eventClose = None
self.itemDataDict = {}
self.tooltipItem = None
def __del__(self):
print("---------------------------------------------------------------------------- DELETE EQUIPMENT DIALOG ")
ui.ScriptWindow.__del__(self)
def __LoadDialog(self):
try:
PythonScriptLoader = ui.PythonScriptLoader()
PythonScriptLoader.LoadScriptFile(self, "UIScript/EquipmentDialog.py")
getObject = self.GetChild
self.board = getObject("Board")
self.slotWindow = getObject("EquipmentSlot")
except:
import exception
exception.Abort("EquipmentDialog.LoadDialog.BindObject")
self.board.SetCloseEvent(ui.__mem_func__(self.Close))
self.slotWindow.SetOverInItemEvent(ui.__mem_func__(self.OverInItem))
self.slotWindow.SetOverOutItemEvent(ui.__mem_func__(self.OverOutItem))
def Open(self, vid):
self.vid = vid
self.itemDataDict = {}
name = chr.GetNameByVID(vid)
self.board.SetTitleName(name)
self.SetCenterPosition()
self.SetTop()
self.Show()
def Close(self):
self.itemDataDict = {}
self.tooltipItem = None
self.Hide()
if self.eventClose:
self.eventClose(self.vid)
def Destroy(self):
self.eventClose = None
self.Close()
self.ClearDictionary()
self.board = None
self.slotWindow = None
def SetEquipmentDialogItem(self, slotIndex, vnum, count):
if count <= 1:
count = 0
self.slotWindow.SetItemSlot(slotIndex, vnum, count)
emptySocketList = []
emptyAttrList = []
for i in range(player.METIN_SOCKET_MAX_NUM):
emptySocketList.append(0)
for i in range(player.ATTRIBUTE_SLOT_MAX_NUM):
emptyAttrList.append((0, 0))
self.itemDataDict[slotIndex] = (vnum, count, emptySocketList, emptyAttrList)
def SetEquipmentDialogSocket(self, slotIndex, socketIndex, value):
if not slotIndex in self.itemDataDict:
return
if socketIndex < 0 or socketIndex > player.METIN_SOCKET_MAX_NUM:
return
self.itemDataDict[slotIndex][2][socketIndex] = value
def SetEquipmentDialogAttr(self, slotIndex, attrIndex, type, value):
if not slotIndex in self.itemDataDict:
return
if attrIndex < 0 or attrIndex > player.ATTRIBUTE_SLOT_MAX_NUM:
return
self.itemDataDict[slotIndex][3][attrIndex] = (type, value)
def SetItemToolTip(self, tooltipItem):
self.tooltipItem = tooltipItem
def SetCloseEvent(self, event):
self.eventClose = event
def OverInItem(self, slotIndex):
if None == self.tooltipItem:
return
if not slotIndex in self.itemDataDict:
return
itemVnum = self.itemDataDict[slotIndex][0]
if 0 == itemVnum:
return
self.tooltipItem.ClearToolTip()
metinSlot = self.itemDataDict[slotIndex][2]
attrSlot = self.itemDataDict[slotIndex][3]
self.tooltipItem.AddItemData(itemVnum, metinSlot, attrSlot)
self.tooltipItem.ShowToolTip()
def OverOutItem(self):
if None != self.tooltipItem:
self.tooltipItem.HideToolTip()
def OnPressEscapeKey(self):
self.Close()
return True
-75
View File
@@ -1,75 +0,0 @@
import app
import wndMgr
import systemSetting
import mouseModule
import ui
class Window(ui.Window):
def __init__(self, skinFileName = ""):
ui.Window.__init__(self, "UI")
self.children = []
self.childDict = {}
self.__LoadSkin(skinFileName)
self.Show()
def __del__(self):
ui.Window.__del__(self)
def ClearDictionary(self):
self.children = []
self.childDict = {}
def InsertChild(self, name, child):
self.childDict[name] = child
def IsChild(self, name):
return name in self.childDict
def GetChild(self, name):
return self.childDict[name]
def __LoadSkin(self, fileName):
loader = ui.PythonScriptLoader()
loader.LoadScriptFile(self, fileName)
#wndMgr.SetOutlineFlag(True)
class App:
def __init__(self, title = "METIN2 UI TEST"):
app.SetMouseHandler(mouseModule.mouseController)
app.SetHairColorEnable(True)
wndMgr.SetMouseHandler(mouseModule.mouseController)
width = systemSetting.GetWidth()
height = systemSetting.GetHeight()
wndMgr.SetScreenSize(width, height)
app.Create(title, width, height, 1)
mouseModule.mouseController.Create()
self.OnInit()
def MainLoop(self):
app.Loop()
def OnInit(self):
pass
if __name__ == "__main__":
class TestWindow(Window):
def __init__(self, skinFileName):
Window.__init__(self, skinFileName)
def __del__(self):
Window.__del__(self)
class TestApp(App):
def OnInit(self):
self.test = TestWindow("locale/ymir_ui/matrixwindow.py")
pass
TestApp().MainLoop()
-232
View File
@@ -1,232 +0,0 @@
import player
import exchange
import net
import localeInfo
import chat
import item
import ui
import mouseModule
import uiPickMoney
import wndMgr
import constInfo
###################################################################################################
## Exchange
class ExchangeDialog(ui.ScriptWindow):
def __init__(self):
ui.ScriptWindow.__init__(self)
self.TitleName = 0
self.tooltipItem = 0
self.xStart = 0
self.yStart = 0
def __del__(self):
ui.ScriptWindow.__del__(self)
def LoadDialog(self):
PythonScriptLoader = ui.PythonScriptLoader()
PythonScriptLoader.LoadScriptFile(self, "UIScript/exchangedialog.py")
## Owner
self.OwnerSlot = self.GetChild("Owner_Slot")
self.OwnerSlot.SetSelectEmptySlotEvent(ui.__mem_func__(self.SelectOwnerEmptySlot))
self.OwnerSlot.SetSelectItemSlotEvent(ui.__mem_func__(self.SelectOwnerItemSlot))
self.OwnerSlot.SetOverInItemEvent(ui.__mem_func__(self.OverInOwnerItem))
self.OwnerSlot.SetOverOutItemEvent(ui.__mem_func__(self.OverOutItem))
self.OwnerMoney = self.GetChild("Owner_Money_Value")
self.OwnerAcceptLight = self.GetChild("Owner_Accept_Light")
self.OwnerAcceptLight.Disable()
self.OwnerMoneyButton = self.GetChild("Owner_Money")
self.OwnerMoneyButton.SetEvent(ui.__mem_func__(self.OpenPickMoneyDialog))
## Target
self.TargetSlot = self.GetChild("Target_Slot")
self.TargetSlot.SetOverInItemEvent(ui.__mem_func__(self.OverInTargetItem))
self.TargetSlot.SetOverOutItemEvent(ui.__mem_func__(self.OverOutItem))
self.TargetMoney = self.GetChild("Target_Money_Value")
self.TargetAcceptLight = self.GetChild("Target_Accept_Light")
self.TargetAcceptLight.Disable()
## PickMoneyDialog
dlgPickMoney = uiPickMoney.PickMoneyDialog()
dlgPickMoney.LoadDialog()
dlgPickMoney.SetAcceptEvent(ui.__mem_func__(self.OnPickMoney))
dlgPickMoney.SetTitleName(localeInfo.EXCHANGE_MONEY)
dlgPickMoney.SetMax(7)
dlgPickMoney.Hide()
self.dlgPickMoney = dlgPickMoney
## Button
self.AcceptButton = self.GetChild("Owner_Accept_Button")
self.AcceptButton.SetToggleDownEvent(ui.__mem_func__(self.AcceptExchange))
self.TitleName = self.GetChild("TitleName")
self.GetChild("TitleBar").SetCloseEvent(net.SendExchangeExitPacket)
def Destroy(self):
print("---------------------------------------------------------------------------- DESTROY EXCHANGE")
self.ClearDictionary()
self.dlgPickMoney.Destroy()
self.dlgPickMoney = 0
self.OwnerSlot = 0
self.OwnerMoney = 0
self.OwnerAcceptLight = 0
self.OwnerMoneyButton = 0
self.TargetSlot = 0
self.TargetMoney = 0
self.TargetAcceptLight = 0
self.TitleName = 0
self.AcceptButton = 0
self.tooltipItem = 0
def OpenDialog(self):
self.TitleName.SetText(localeInfo.EXCHANGE_TITLE % (exchange.GetNameFromTarget()))
self.AcceptButton.Enable()
self.AcceptButton.SetUp()
self.Show()
(self.xStart, self.yStart, z) = player.GetMainCharacterPosition()
def CloseDialog(self):
wndMgr.OnceIgnoreMouseLeftButtonUpEvent()
if 0 != self.tooltipItem:
self.tooltipItem.HideToolTip()
self.dlgPickMoney.Close()
self.Hide()
def SetItemToolTip(self, tooltipItem):
self.tooltipItem = tooltipItem
def OpenPickMoneyDialog(self):
if exchange.GetElkFromSelf() > 0:
chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.EXCHANGE_CANT_EDIT_MONEY)
return
self.dlgPickMoney.Open(player.GetElk())
def OnPickMoney(self, money):
net.SendExchangeElkAddPacket(money)
def AcceptExchange(self):
net.SendExchangeAcceptPacket()
self.AcceptButton.Disable()
def SelectOwnerEmptySlot(self, SlotIndex):
if False == mouseModule.mouseController.isAttached():
return
if mouseModule.mouseController.IsAttachedMoney():
net.SendExchangeElkAddPacket(mouseModule.mouseController.GetAttachedMoneyAmount())
else:
attachedSlotType = mouseModule.mouseController.GetAttachedType()
if (player.SLOT_TYPE_INVENTORY == attachedSlotType
or player.SLOT_TYPE_DRAGON_SOUL_INVENTORY == attachedSlotType):
attachedInvenType = player.SlotTypeToInvenType(attachedSlotType)
SrcSlotNumber = mouseModule.mouseController.GetAttachedSlotNumber()
DstSlotNumber = SlotIndex
itemID = player.GetItemIndex(attachedInvenType, SrcSlotNumber)
# MR-3: Auto-deactivate auto potions before moving out
if attachedSlotType == player.SLOT_TYPE_INVENTORY:
itemVnum = player.GetItemIndex(attachedInvenType, SrcSlotNumber)
if constInfo.IS_AUTO_POTION(itemVnum):
metinSocket = [player.GetItemMetinSocket(attachedInvenType, SrcSlotNumber, j) for j in range(player.METIN_SOCKET_MAX_NUM)]
isActivated = (0 != int(metinSocket[0]))
if isActivated:
net.SendItemUsePacket(SrcSlotNumber)
# MR-3: -- END OF -- Auto-deactivate auto potions before moving out
item.SelectItem(itemID)
if item.IsAntiFlag(item.ANTIFLAG_GIVE):
chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.EXCHANGE_CANNOT_GIVE)
mouseModule.mouseController.DeattachObject()
return
net.SendExchangeItemAddPacket(attachedInvenType, SrcSlotNumber, DstSlotNumber)
mouseModule.mouseController.DeattachObject()
def SelectOwnerItemSlot(self, SlotIndex):
if player.ITEM_MONEY == mouseModule.mouseController.GetAttachedItemIndex():
money = mouseModule.mouseController.GetAttachedItemCount()
net.SendExchangeElkAddPacket(money)
def RefreshOwnerSlot(self):
for i in range(exchange.EXCHANGE_ITEM_MAX_NUM):
itemIndex = exchange.GetItemVnumFromSelf(i)
itemCount = exchange.GetItemCountFromSelf(i)
if 1 == itemCount:
itemCount = 0
self.OwnerSlot.SetItemSlot(i, itemIndex, itemCount)
self.OwnerSlot.RefreshSlot()
def RefreshTargetSlot(self):
for i in range(exchange.EXCHANGE_ITEM_MAX_NUM):
itemIndex = exchange.GetItemVnumFromTarget(i)
itemCount = exchange.GetItemCountFromTarget(i)
if 1 == itemCount:
itemCount = 0
self.TargetSlot.SetItemSlot(i, itemIndex, itemCount)
self.TargetSlot.RefreshSlot()
def Refresh(self):
self.RefreshOwnerSlot()
self.RefreshTargetSlot()
# self.OwnerMoney.SetText(str(exchange.GetElkFromSelf()))
# self.TargetMoney.SetText(str(exchange.GetElkFromTarget()))
self.OwnerMoney.SetText(str(('.'.join([ i-3<0 and str(exchange.GetElkFromSelf())[:i] or str(exchange.GetElkFromSelf())[i-3:i] for i in range(len(str(exchange.GetElkFromSelf()))%3, len(str(exchange.GetElkFromSelf()))+1, 3) if i ]))))
self.TargetMoney.SetText(str(('.'.join([ i-3<0 and str(exchange.GetElkFromTarget())[:i] or str(exchange.GetElkFromTarget())[i-3:i] for i in range(len(str(exchange.GetElkFromTarget()))%3, len(str(exchange.GetElkFromTarget()))+1, 3) if i ]))))
if True == exchange.GetAcceptFromSelf():
self.OwnerAcceptLight.Down()
else:
self.AcceptButton.Enable()
self.AcceptButton.SetUp()
self.OwnerAcceptLight.SetUp()
if True == exchange.GetAcceptFromTarget():
self.TargetAcceptLight.Down()
else:
self.TargetAcceptLight.SetUp()
def OverInOwnerItem(self, slotIndex):
if 0 != self.tooltipItem:
self.tooltipItem.SetExchangeOwnerItem(slotIndex)
def OverInTargetItem(self, slotIndex):
if 0 != self.tooltipItem:
self.tooltipItem.SetExchangeTargetItem(slotIndex)
def OverOutItem(self):
if 0 != self.tooltipItem:
self.tooltipItem.HideToolTip()
def OnTop(self):
self.tooltipItem.SetTop()
def OnUpdate(self):
USE_EXCHANGE_LIMIT_RANGE = 1000
(x, y, z) = player.GetMainCharacterPosition()
if abs(x - self.xStart) > USE_EXCHANGE_LIMIT_RANGE or abs(y - self.yStart) > USE_EXCHANGE_LIMIT_RANGE:
(self.xStart, self.yStart, z) = player.GetMainCharacterPosition()
net.SendExchangeExitPacket()
-107
View File
@@ -1,107 +0,0 @@
import app
import ui
import player
import net
class GameButtonWindow(ui.ScriptWindow):
def __init__(self):
ui.ScriptWindow.__init__(self)
self.__LoadWindow("UIScript/gamewindow.py")
def __del__(self):
ui.ScriptWindow.__del__(self)
def __LoadWindow(self, filename):
try:
pyScrLoader = ui.PythonScriptLoader()
pyScrLoader.LoadScriptFile(self, filename)
except Exception as msg:
import dbg
dbg.TraceError("GameButtonWindow.LoadScript - %s" % (msg))
app.Abort()
return False
try:
self.gameButtonDict={
"STATUS" : self.GetChild("StatusPlusButton"),
"SKILL" : self.GetChild("SkillPlusButton"),
"QUEST" : self.GetChild("QuestButton"),
"HELP" : self.GetChild("HelpButton"),
"BUILD" : self.GetChild("BuildGuildBuilding"),
"EXIT_OBSERVER" : self.GetChild("ExitObserver"),
}
self.gameButtonDict["EXIT_OBSERVER"].SetEvent(ui.__mem_func__(self.__OnClickExitObserver))
except Exception as msg:
import dbg
dbg.TraceError("GameButtonWindow.LoadScript - %s" % (msg))
app.Abort()
return False
self.__HideAllGameButton()
self.SetObserverMode(player.IsObserverMode())
return True
def Destroy(self):
for key in self.gameButtonDict:
self.gameButtonDict[key].SetEvent(0)
self.gameButtonDict={}
def SetButtonEvent(self, name, event):
try:
self.gameButtonDict[name].SetEvent(event)
except Exception as msg:
print(("GameButtonWindow.LoadScript - %s" % (msg)))
app.Abort()
return
def ShowBuildButton(self):
self.gameButtonDict["BUILD"].Show()
def HideBuildButton(self):
self.gameButtonDict["BUILD"].Hide()
def CheckGameButton(self):
if not self.IsShow():
return
statusPlusButton=self.gameButtonDict["STATUS"]
skillPlusButton=self.gameButtonDict["SKILL"]
helpButton=self.gameButtonDict["HELP"]
if player.GetStatus(player.STAT) > 0:
statusPlusButton.Show()
else:
statusPlusButton.Hide()
if self.__IsSkillStat():
skillPlusButton.Show()
else:
skillPlusButton.Hide()
if 0 == player.GetPlayTime():
helpButton.Show()
else:
helpButton.Hide()
def __IsSkillStat(self):
if player.GetStatus(player.SKILL_ACTIVE) > 0:
return True
return False
def __OnClickExitObserver(self):
net.SendChatPacket("/observer_exit")
def __HideAllGameButton(self):
for btn in list(self.gameButtonDict.values()):
btn.Hide()
def SetObserverMode(self, isEnable):
if isEnable:
self.gameButtonDict["EXIT_OBSERVER"].Show()
else:
self.gameButtonDict["EXIT_OBSERVER"].Hide()
-370
View File
@@ -1,370 +0,0 @@
import ui
import snd
import systemSetting
import net
import chat
import app
import localeInfo
import constInfo
import chrmgr
import player
import uiPrivateShopBuilder # 占쏙옙占쏙옙호
import interfaceModule # 占쏙옙占쏙옙호
blockMode = 0
viewChatMode = 0
class OptionDialog(ui.ScriptWindow):
def __init__(self):
ui.ScriptWindow.__init__(self)
self.__Initialize()
self.__Load()
self.RefreshViewChat()
self.RefreshAlwaysShowName()
self.RefreshShowDamage()
self.RefreshShowSalesText()
def __del__(self):
ui.ScriptWindow.__del__(self)
print(" -------------------------------------- DELETE GAME OPTION DIALOG")
def __Initialize(self):
self.titleBar = 0
self.nameColorModeButtonList = []
self.viewTargetBoardButtonList = []
self.pvpModeButtonDict = {}
self.blockButtonList = []
self.viewChatButtonList = []
self.alwaysShowNameButtonList = []
self.showDamageButtonList = []
self.showsalesTextButtonList = []
def Destroy(self):
self.ClearDictionary()
self.__Initialize()
print(" -------------------------------------- DESTROY GAME OPTION DIALOG")
def __Load_LoadScript(self, fileName):
try:
pyScriptLoader = ui.PythonScriptLoader()
pyScriptLoader.LoadScriptFile(self, fileName)
except:
import exception
exception.Abort("OptionDialog.__Load_LoadScript")
def __Load_BindObject(self):
try:
GetObject = self.GetChild
self.titleBar = GetObject("titlebar")
self.nameColorModeButtonList.append(GetObject("name_color_normal"))
self.nameColorModeButtonList.append(GetObject("name_color_empire"))
self.viewTargetBoardButtonList.append(GetObject("target_board_no_view"))
self.viewTargetBoardButtonList.append(GetObject("target_board_view"))
self.pvpModeButtonDict[player.PK_MODE_PEACE] = GetObject("pvp_peace")
self.pvpModeButtonDict[player.PK_MODE_REVENGE] = GetObject("pvp_revenge")
self.pvpModeButtonDict[player.PK_MODE_GUILD] = GetObject("pvp_guild")
self.pvpModeButtonDict[player.PK_MODE_FREE] = GetObject("pvp_free")
self.blockButtonList.append(GetObject("block_exchange_button"))
self.blockButtonList.append(GetObject("block_party_button"))
self.blockButtonList.append(GetObject("block_guild_button"))
self.blockButtonList.append(GetObject("block_whisper_button"))
self.blockButtonList.append(GetObject("block_friend_button"))
self.blockButtonList.append(GetObject("block_party_request_button"))
self.viewChatButtonList.append(GetObject("view_chat_on_button"))
self.viewChatButtonList.append(GetObject("view_chat_off_button"))
self.alwaysShowNameButtonList.append(GetObject("always_show_name_on_button"))
self.alwaysShowNameButtonList.append(GetObject("always_show_name_off_button"))
self.showDamageButtonList.append(GetObject("show_damage_on_button"))
self.showDamageButtonList.append(GetObject("show_damage_off_button"))
self.showsalesTextButtonList.append(GetObject("salestext_on_button"))
self.showsalesTextButtonList.append(GetObject("salestext_off_button"))
except:
import exception
exception.Abort("OptionDialog.__Load_BindObject")
def __Load(self):
self.__Load_LoadScript("uiscript/gameoptiondialog.py")
self.__Load_BindObject()
self.SetCenterPosition()
self.titleBar.SetCloseEvent(ui.__mem_func__(self.Close))
self.nameColorModeButtonList[0].SAFE_SetEvent(self.__OnClickNameColorModeNormalButton)
self.nameColorModeButtonList[1].SAFE_SetEvent(self.__OnClickNameColorModeEmpireButton)
self.viewTargetBoardButtonList[0].SAFE_SetEvent(self.__OnClickTargetBoardViewButton)
self.viewTargetBoardButtonList[1].SAFE_SetEvent(self.__OnClickTargetBoardNoViewButton)
self.pvpModeButtonDict[player.PK_MODE_PEACE].SAFE_SetEvent(self.__OnClickPvPModePeaceButton)
self.pvpModeButtonDict[player.PK_MODE_REVENGE].SAFE_SetEvent(self.__OnClickPvPModeRevengeButton)
self.pvpModeButtonDict[player.PK_MODE_GUILD].SAFE_SetEvent(self.__OnClickPvPModeGuildButton)
self.pvpModeButtonDict[player.PK_MODE_FREE].SAFE_SetEvent(self.__OnClickPvPModeFreeButton)
self.blockButtonList[0].SetToggleUpEvent(self.__OnClickBlockExchangeButton)
self.blockButtonList[1].SetToggleUpEvent(self.__OnClickBlockPartyButton)
self.blockButtonList[2].SetToggleUpEvent(self.__OnClickBlockGuildButton)
self.blockButtonList[3].SetToggleUpEvent(self.__OnClickBlockWhisperButton)
self.blockButtonList[4].SetToggleUpEvent(self.__OnClickBlockFriendButton)
self.blockButtonList[5].SetToggleUpEvent(self.__OnClickBlockPartyRequest)
self.blockButtonList[0].SetToggleDownEvent(self.__OnClickBlockExchangeButton)
self.blockButtonList[1].SetToggleDownEvent(self.__OnClickBlockPartyButton)
self.blockButtonList[2].SetToggleDownEvent(self.__OnClickBlockGuildButton)
self.blockButtonList[3].SetToggleDownEvent(self.__OnClickBlockWhisperButton)
self.blockButtonList[4].SetToggleDownEvent(self.__OnClickBlockFriendButton)
self.blockButtonList[5].SetToggleDownEvent(self.__OnClickBlockPartyRequest)
self.viewChatButtonList[0].SAFE_SetEvent(self.__OnClickViewChatOnButton)
self.viewChatButtonList[1].SAFE_SetEvent(self.__OnClickViewChatOffButton)
self.alwaysShowNameButtonList[0].SAFE_SetEvent(self.__OnClickAlwaysShowNameOnButton)
self.alwaysShowNameButtonList[1].SAFE_SetEvent(self.__OnClickAlwaysShowNameOffButton)
self.showDamageButtonList[0].SAFE_SetEvent(self.__OnClickShowDamageOnButton)
self.showDamageButtonList[1].SAFE_SetEvent(self.__OnClickShowDamageOffButton)
self.showsalesTextButtonList[0].SAFE_SetEvent(self.__OnClickSalesTextOnButton)
self.showsalesTextButtonList[1].SAFE_SetEvent(self.__OnClickSalesTextOffButton)
self.__ClickRadioButton(self.nameColorModeButtonList, constInfo.GET_CHRNAME_COLOR_INDEX())
self.__ClickRadioButton(self.viewTargetBoardButtonList, constInfo.GET_VIEW_OTHER_EMPIRE_PLAYER_TARGET_BOARD())
self.__SetPeacePKMode()
def __ClickRadioButton(self, buttonList, buttonIndex):
try:
selButton=buttonList[buttonIndex]
except IndexError:
return
for eachButton in buttonList:
eachButton.SetUp()
selButton.Down()
def __SetNameColorMode(self, index):
constInfo.SET_CHRNAME_COLOR_INDEX(index)
self.__ClickRadioButton(self.nameColorModeButtonList, index)
def __SetTargetBoardViewMode(self, flag):
constInfo.SET_VIEW_OTHER_EMPIRE_PLAYER_TARGET_BOARD(flag)
self.__ClickRadioButton(self.viewTargetBoardButtonList, flag)
def __OnClickNameColorModeNormalButton(self):
self.__SetNameColorMode(0)
def __OnClickNameColorModeEmpireButton(self):
self.__SetNameColorMode(1)
def __OnClickTargetBoardViewButton(self):
self.__SetTargetBoardViewMode(0)
def __OnClickTargetBoardNoViewButton(self):
self.__SetTargetBoardViewMode(1)
def __OnClickCameraModeShortButton(self):
self.__SetCameraMode(0)
def __OnClickCameraModeLongButton(self):
self.__SetCameraMode(1)
def __OnClickFogModeLevel0Button(self):
self.__SetFogLevel(0)
def __OnClickFogModeLevel1Button(self):
self.__SetFogLevel(1)
def __OnClickFogModeLevel2Button(self):
self.__SetFogLevel(2)
def __OnClickBlockExchangeButton(self):
self.RefreshBlock()
global blockMode
net.SendChatPacket("/setblockmode " + str(blockMode ^ player.BLOCK_EXCHANGE))
def __OnClickBlockPartyButton(self):
self.RefreshBlock()
global blockMode
net.SendChatPacket("/setblockmode " + str(blockMode ^ player.BLOCK_PARTY))
def __OnClickBlockGuildButton(self):
self.RefreshBlock()
global blockMode
net.SendChatPacket("/setblockmode " + str(blockMode ^ player.BLOCK_GUILD))
def __OnClickBlockWhisperButton(self):
self.RefreshBlock()
global blockMode
net.SendChatPacket("/setblockmode " + str(blockMode ^ player.BLOCK_WHISPER))
def __OnClickBlockFriendButton(self):
self.RefreshBlock()
global blockMode
net.SendChatPacket("/setblockmode " + str(blockMode ^ player.BLOCK_FRIEND))
def __OnClickBlockPartyRequest(self):
self.RefreshBlock()
global blockMode
net.SendChatPacket("/setblockmode " + str(blockMode ^ player.BLOCK_PARTY_REQUEST))
def __OnClickViewChatOnButton(self):
global viewChatMode
viewChatMode = 1
systemSetting.SetViewChatFlag(viewChatMode)
self.RefreshViewChat()
def __OnClickViewChatOffButton(self):
global viewChatMode
viewChatMode = 0
systemSetting.SetViewChatFlag(viewChatMode)
self.RefreshViewChat()
def __OnClickAlwaysShowNameOnButton(self):
systemSetting.SetAlwaysShowNameFlag(True)
self.RefreshAlwaysShowName()
def __OnClickAlwaysShowNameOffButton(self):
systemSetting.SetAlwaysShowNameFlag(False)
self.RefreshAlwaysShowName()
def __OnClickShowDamageOnButton(self):
systemSetting.SetShowDamageFlag(True)
self.RefreshShowDamage()
def __OnClickShowDamageOffButton(self):
systemSetting.SetShowDamageFlag(False)
self.RefreshShowDamage()
def __OnClickSalesTextOnButton(self):
systemSetting.SetShowSalesTextFlag(True)
self.RefreshShowSalesText()
uiPrivateShopBuilder.UpdateADBoard()
def __OnClickSalesTextOffButton(self):
systemSetting.SetShowSalesTextFlag(False)
self.RefreshShowSalesText()
def __CheckPvPProtectedLevelPlayer(self):
if player.GetStatus(player.LEVEL)<constInfo.PVPMODE_PROTECTED_LEVEL:
self.__SetPeacePKMode()
chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.OPTION_PVPMODE_PROTECT % (constInfo.PVPMODE_PROTECTED_LEVEL))
return 1
return 0
def __SetPKMode(self, mode):
for btn in list(self.pvpModeButtonDict.values()):
btn.SetUp()
if mode in self.pvpModeButtonDict:
self.pvpModeButtonDict[mode].Down()
def __SetPeacePKMode(self):
self.__SetPKMode(player.PK_MODE_PEACE)
def __RefreshPVPButtonList(self):
self.__SetPKMode(player.GetPKMode())
def __OnClickPvPModePeaceButton(self):
if self.__CheckPvPProtectedLevelPlayer():
return
self.__RefreshPVPButtonList()
if constInfo.PVPMODE_ENABLE:
net.SendChatPacket("/pkmode 0", chat.CHAT_TYPE_TALKING)
else:
chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.OPTION_PVPMODE_NOT_SUPPORT)
def __OnClickPvPModeRevengeButton(self):
if self.__CheckPvPProtectedLevelPlayer():
return
self.__RefreshPVPButtonList()
if constInfo.PVPMODE_ENABLE:
net.SendChatPacket("/pkmode 1", chat.CHAT_TYPE_TALKING)
else:
chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.OPTION_PVPMODE_NOT_SUPPORT)
def __OnClickPvPModeFreeButton(self):
if self.__CheckPvPProtectedLevelPlayer():
return
self.__RefreshPVPButtonList()
if constInfo.PVPMODE_ENABLE:
net.SendChatPacket("/pkmode 2", chat.CHAT_TYPE_TALKING)
else:
chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.OPTION_PVPMODE_NOT_SUPPORT)
def __OnClickPvPModeGuildButton(self):
if self.__CheckPvPProtectedLevelPlayer():
return
self.__RefreshPVPButtonList()
if 0 == player.GetGuildID():
chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.OPTION_PVPMODE_CANNOT_SET_GUILD_MODE)
return
if constInfo.PVPMODE_ENABLE:
net.SendChatPacket("/pkmode 4", chat.CHAT_TYPE_TALKING)
else:
chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.OPTION_PVPMODE_NOT_SUPPORT)
def OnChangePKMode(self):
self.__RefreshPVPButtonList()
def OnPressEscapeKey(self):
self.Close()
return True
def RefreshBlock(self):
global blockMode
for i in range(len(self.blockButtonList)):
if 0 != (blockMode & (1 << i)):
self.blockButtonList[i].Down()
else:
self.blockButtonList[i].SetUp()
def RefreshViewChat(self):
if systemSetting.IsViewChat():
self.viewChatButtonList[0].Down()
self.viewChatButtonList[1].SetUp()
else:
self.viewChatButtonList[0].SetUp()
self.viewChatButtonList[1].Down()
def RefreshAlwaysShowName(self):
if systemSetting.IsAlwaysShowName():
self.alwaysShowNameButtonList[0].Down()
self.alwaysShowNameButtonList[1].SetUp()
else:
self.alwaysShowNameButtonList[0].SetUp()
self.alwaysShowNameButtonList[1].Down()
def RefreshShowDamage(self):
if systemSetting.IsShowDamage():
self.showDamageButtonList[0].Down()
self.showDamageButtonList[1].SetUp()
else:
self.showDamageButtonList[0].SetUp()
self.showDamageButtonList[1].Down()
def RefreshShowSalesText(self):
if systemSetting.IsShowSalesText():
self.showsalesTextButtonList[0].Down()
self.showsalesTextButtonList[1].SetUp()
else:
self.showsalesTextButtonList[0].SetUp()
self.showsalesTextButtonList[1].Down()
def OnBlockMode(self, mode):
global blockMode
blockMode = mode
self.RefreshBlock()
def Show(self):
self.RefreshBlock()
ui.ScriptWindow.Show(self)
def Close(self):
self.Hide()
File diff suppressed because it is too large Load Diff
-136
View File
@@ -1,136 +0,0 @@
import app
import ui
import localeInfo
import uiScriptLocale
ENABLE_HELP_MULTIPAGE = 0
class HelpWindow(ui.ScriptWindow):
def __init__(self):
ui.ScriptWindow.__init__(self, "TOP_MOST")
self.eventClose = 0
def __del__(self):
ui.ScriptWindow.__del__(self)
def LoadDialog(self):
if ENABLE_HELP_MULTIPAGE:
self.LoadDialogMultiPage()
else:
self.LoadDialogSinglePage()
def LoadDialogSinglePage(self):
try:
pyScrLoader = ui.PythonScriptLoader()
pyScrLoader.LoadScriptFile(self, "UIScript/HelpWindow.py")
except:
import exception
exception.Abort("HelpWindow.LoadDialogSinglePage.LoadScript")
try:
GetObject=self.GetChild
self.btnClose = GetObject("close_button")
except:
import exception
exception.Abort("DialogWindow.LoadDialogSinglePage.BindObject")
def LoadDialogMultiPage(self):
try:
pyScrLoader = ui.PythonScriptLoader()
pyScrLoader.LoadScriptFile(self, "UIScript/HelpWindow2.py")
except:
import exception
exception.Abort("HelpWindow.LoadDialogMultiPage.LoadScript")
try:
GetObject=self.GetChild
self.btnClose = GetObject("close_button")
self.pages = {}
self.btnPages = {}
self.pages[0] = GetObject("page_1")
self.pages[1] = GetObject("page_2")
self.btnPages[0] = GetObject("page_1_button")
self.btnPages[1] = GetObject("page_2_button")
self.btnPages[0].SAFE_SetEvent(self.__OnClickPage1)
self.btnPages[1].SAFE_SetEvent(self.__OnClickPage2)
self.__SelectPage(0)
except:
import exception
exception.Abort("DialogWindow.LoadDialogMultiPage.BindObject")
def __OnClickPage1(self):
self.__SelectPage(0)
def __OnClickPage2(self):
self.__SelectPage(1)
def Destroy(self):
self.eventClose = 0
self.closeButton = 0
self.pages = {}
self.btnPages = {}
def SetCloseEvent(self, event):
self.eventClose = event
self.btnClose.SetEvent(event)
def Open(self):
self.Lock()
self.Show()
def Close(self):
self.Unlock()
self.Hide()
def OnKeyDown(self, key):
if app.DIK_H == key and 0 != self.eventClose:
self.eventClose()
return True
def OnIMEReturn(self):
return True
def OnPressEscapeKey(self):
if 0 != self.eventClose:
self.eventClose()
return True
def OnPressExitKey(self):
if 0 != self.eventClose:
self.eventClose()
return True
def __SelectPage(self, pageIndex):
for page in list(self.pages.values()):
page.Hide()
for btn in list(self.btnPages.values()):
btn.SetUp()
self.pages[pageIndex].Show()
self.btnPages[pageIndex].Down()
if __name__ == "__main__":
import app
import wndMgr
import systemSetting
import mouseModule
import grp
import ui
app.SetMouseHandler(mouseModule.mouseController)
app.SetHairColorEnable(True)
wndMgr.SetMouseHandler(mouseModule.mouseController)
wndMgr.SetScreenSize(systemSetting.GetWidth(), systemSetting.GetHeight())
app.Create(localeInfo.APP_TITLE, systemSetting.GetWidth(), systemSetting.GetHeight(), 1)
mouseModule.mouseController.Create()
wnd = HelpWindow()
wnd.LoadDialog()
wnd.Open()
app.Loop()
wnd = None
File diff suppressed because it is too large Load Diff
-64
View File
@@ -1,64 +0,0 @@
"""
Generic UI Locale Refresh System
Provides RefreshByMapping and RebuildDictionary for hot-reload support.
"""
import dbg
def RefreshByMapping(elementMap):
"""
Refresh UI elements using a mapping dictionary.
Args:
elementMap: Dict of {element_instance: "LOCALE_KEY_NAME"}
Returns:
Number of elements successfully refreshed
"""
import uiScriptLocale
import localeInfo
refreshCount = 0
for element, localeKey in list(elementMap.items()):
try:
# Try uiScriptLocale first, then localeInfo
if hasattr(uiScriptLocale, localeKey):
text = getattr(uiScriptLocale, localeKey)
elif hasattr(localeInfo, localeKey):
text = getattr(localeInfo, localeKey)
else:
dbg.TraceError("LocaleRefresh: key not found: %s" % localeKey)
continue
if hasattr(element, 'SetText'):
element.SetText(text)
refreshCount += 1
except Exception as e:
dbg.TraceError("LocaleRefresh: failed for key %s: %s" % (localeKey, str(e)))
return refreshCount
def RebuildDictionary(template, localeModule="localeInfo"):
"""
Rebuild a dictionary with fresh locale strings.
Args:
template: Dict of {key: "LOCALE_CONSTANT_NAME"}
localeModule: "localeInfo" or "uiScriptLocale"
Returns:
New dictionary with resolved locale values
"""
import localeInfo
import uiScriptLocale
module = localeInfo if localeModule == "localeInfo" else uiScriptLocale
newDict = {}
for key, localeKey in list(template.items()):
if hasattr(module, localeKey):
newDict[key] = getattr(module, localeKey)
else:
dbg.TraceError("LocaleRefresh: key not found: %s" % localeKey)
return newDict
-192
View File
@@ -1,192 +0,0 @@
# -*- coding: utf-8 -*-
"""
Locale Selector UI Component
=============================
A reusable UI component for selecting and changing the client language.
Can be added to any window (login, game settings, etc.).
Usage:
from uilocaleselector import LocaleSelector
# In your window class:
self.localeSelector = LocaleSelector()
self.localeSelector.Create(self)
self.localeSelector.SetLocaleChangedEvent(ui.__mem_func__(self.__OnLocaleChanged))
# Implement the callback:
def __OnLocaleChanged(self, newLocaleCode):
# Handle UI recreation here
pass
"""
import ui
import uiCommon
import localeInfo
import wndMgr
# Available locales configuration
AVAILABLE_LOCALES = [
{"code": "ae", "name": "Arabic", "flag": "ae"},
{"code": "br", "name": "Português Brasileiro", "flag": "br"},
{"code": "en", "name": "English", "flag": "en"},
{"code": "cz", "name": "Čeština", "flag": "cz"},
{"code": "de", "name": "Deutsch", "flag": "de"},
{"code": "dk", "name": "Dansk", "flag": "dk"},
{"code": "es", "name": "Español", "flag": "es"},
{"code": "fr", "name": "Français", "flag": "fr"},
{"code": "gr", "name": "Ελληνικά", "flag": "gr"},
{"code": "hu", "name": "Magyar", "flag": "hu"},
{"code": "it", "name": "Italiano", "flag": "it"},
{"code": "nl", "name": "Nederlands", "flag": "nl"},
{"code": "pl", "name": "Polski", "flag": "pl"},
{"code": "pt", "name": "Português", "flag": "pt"},
{"code": "ro", "name": "Română", "flag": "ro"},
{"code": "ru", "name": "Русский", "flag": "ru"},
{"code": "tr", "name": "Türkçe", "flag": "tr"},
]
# Flag image path template
FLAG_IMAGE_PATH = "d:/ymir work/ui/intro/login/server_flag_%s.sub"
class LocaleSelector(ui.Window):
"""
UI component for selecting and changing client language.
Features:
- Displays flag buttons for all available locales
- Shows confirmation dialog before changing
- Triggers callback when locale is confirmed
- Self-contained and reusable
"""
def __init__(self):
ui.Window.__init__(self)
self.background = None
self.flagButtons = []
self.confirmDialog = None
self.selectedLocaleCode = None
self.eventLocaleChanged = None
def __del__(self):
ui.Window.__del__(self)
def Destroy(self):
"""Clean up resources when destroying the selector."""
self.eventLocaleChanged = None
self.selectedLocaleCode = None
if self.confirmDialog:
self.confirmDialog.Close()
self.confirmDialog = None
for btn in self.flagButtons:
btn.SetEvent(None)
btn.Hide()
self.flagButtons = []
if self.background:
self.background.Hide()
self.background = None
def Create(self, parent):
"""
Create and display the locale selector UI.
Args:
parent: The parent window to attach to
"""
self.SetParent(parent)
self.SetSize(wndMgr.GetScreenWidth(), 35)
self.SetPosition(0, 20)
# Create background board
self.background = ui.ThinBoard()
self.background.SetParent(self)
self.background.SetSize(wndMgr.GetScreenWidth(), 35)
self.background.SetPosition(0, 0)
self.background.Show()
# Create flag buttons
self._CreateFlagButtons()
self.Show()
def _CreateFlagButtons(self):
"""Create flag buttons for all available locales."""
localeCount = len(AVAILABLE_LOCALES)
if localeCount == 0:
return
buttonSpacing = wndMgr.GetScreenWidth() / localeCount
xPosition = 0
for locale in AVAILABLE_LOCALES:
flagPath = FLAG_IMAGE_PATH % locale["flag"]
button = ui.Button()
button.SetParent(self.background)
button.SetPosition(xPosition + 15, 10)
button.SetUpVisual(flagPath)
button.SetOverVisual(flagPath)
button.SetDownVisual(flagPath)
button.SetToolTipText(locale["name"])
button.SetEvent(ui.__mem_func__(self._OnClickFlag), locale["code"])
button.Show()
self.flagButtons.append(button)
xPosition += buttonSpacing
def _OnClickFlag(self, localeCode):
"""
Handle flag button click - show confirmation dialog.
Args:
localeCode: The locale code that was clicked
"""
self.selectedLocaleCode = localeCode
# Get locale name for display
localeName = "Unknown"
for locale in AVAILABLE_LOCALES:
if locale["code"] == localeCode:
localeName = locale["name"]
break
# Show confirmation dialog
if not self.confirmDialog:
self.confirmDialog = uiCommon.QuestionDialog()
self.confirmDialog.SetText(localeInfo.LOCALE_CHANGE_CONFIRM % localeName)
self.confirmDialog.SetAcceptEvent(ui.__mem_func__(self._OnConfirmLocaleChange))
self.confirmDialog.SetCancelEvent(ui.__mem_func__(self._OnCancelLocaleChange))
self.confirmDialog.Open()
def _OnConfirmLocaleChange(self):
"""User confirmed locale change - trigger the callback."""
if self.confirmDialog:
self.confirmDialog.Close()
if not self.selectedLocaleCode:
return
# Notify parent window to handle the locale change
if self.eventLocaleChanged:
self.eventLocaleChanged(self.selectedLocaleCode)
def _OnCancelLocaleChange(self):
"""User cancelled locale change."""
if self.confirmDialog:
self.confirmDialog.Close()
self.selectedLocaleCode = None
def SetLocaleChangedEvent(self, event):
"""
Set callback function to be called when locale is confirmed.
Args:
event: Callback function(localeCode) to handle locale change
"""
self.eventLocaleChanged = event
-211
View File
@@ -1,211 +0,0 @@
import app
import ui
import uiScriptLocale
import localeInfo
LOCALE_PATH = uiScriptLocale.MAPNAME_PATH
# Static map name -> image suffix mapping (locale-independent)
_MAP_NAME_SUFFIXES = {
"metin2_map_a1": "a1.tga",
"map_a2": "a2.tga",
"metin2_map_a3": "a3.tga",
"metin2_map_b1": "b1.tga",
"map_b2": "b2.tga",
"metin2_map_b3": "b3.tga",
"metin2_map_c1": "c1.tga",
"map_c2": "c2.tga",
"metin2_map_c3": "c3.tga",
"map_n_snowm_01": "snow1.tga",
"metin2_map_deviltower1": "devil1_title.tga",
"metin2_map_n_flame_01": "frame1.tga",
"metin2_map_n_desert_01": "desert1.tga",
"metin2_map_milgyo": "milgyo.tga",
"metin2_map_monkeydungeon": "monkey1.tga",
"metin2_map_monkeydungeon_02": "monkey2.tga",
"metin2_map_monkeydungeon_03": "monkey3.tga",
"metin2_map_guild_01": "guild1.tga",
"metin2_map_guild_02": "guild2.tga",
"metin2_map_guild_03": "guild3.tga",
"metin2_map_trent": "trent.tga",
"metin2_map_trent02": "trent02.tga",
"season2/map_n_snowm_02": "snow2.tga",
"season2/metin2_map_a2_1": "a2_2.tga",
"season2/metin2_map_n_desert_02": "desert2.tga",
"season2/metin2_map_n_flame_02": "frame2.tga",
"season2/metin2_map_milgyo_a": "milgyo2.TGA",
"season2/metin2_map_trent_a": "trent_a.tga",
"season2/metin2_map_trent02_a": "trent02_a.tga",
"season2/metin2_map_skipia_dungeon_01": "skipia.tga",
"season2/metin2_map_skipia_dungeon_02": "skipia.tga",
"metin2_map_devilsCatacomb": "devil_basement.tga",
"metin2_guild_village_01": "a4.tga",
"metin2_guild_village_02": "b4.tga",
"metin2_guild_village_03": "c4.tga",
"metin2_map_BayBlackSand": "bay.tga",
"metin2_map_Mt_Thunder": "thunder.tga",
"metin2_map_dawnmistwood": "dawn.tga",
"Metin2_map_CapeDragonHead": "cape.tga",
"metin2_map_spiderdungeon": "spider1.tga",
"metin2_map_spiderdungeon_02": "spider1.tga",
"metin2_map_spiderdungeon_03": "spider1.tga",
}
def _RebuildLocaleStrings():
global LOCALE_PATH
LOCALE_PATH = uiScriptLocale.MAPNAME_PATH
localeInfo.RegisterReloadCallback(_RebuildLocaleStrings)
class MapNameShower(ui.ExpandedImageBox):
STATE_HIDE = 0
STATE_FADE_IN = 1
STATE_SHOW = 2
STATE_FADE_OUT = 3
def __init__(self):
ui.ExpandedImageBox.__init__(self, "TOP_MOST")
self.AddFlag("not_pick")
self.__Initialize()
def __del__(self):
ui.ExpandedImageBox.__del__(self)
def __Initialize(self):
self.floorImage = None
self.objectiveImage = None
self.fadeStartTime = 0
self.state = self.STATE_HIDE
self.curAlpha = 0.0
self.SetAlpha(0.0)
self.SetWindowHorizontalAlignCenter()
self.SetPosition(0, 80)
self.Hide()
def __GetDevilTowerFloor(self, x, y):
if x > 10000 and y > 58000 and x < 25000 and y < 72000:
return 1
elif x > 10000 and y > 35000 and x < 25000 and y < 50000:
return 2
elif x > 10000 and y > 10000 and x < 25000 and y < 25000:
return 3
elif x > 35000 and y > 61000 and x < 43500 and y < 70500:
return 4
elif x > 35000 and y > 38000 and x < 43500 and y < 48000:
return 5
elif x > 14000 and y > 14000 and x < 43500 and y < 24500:
return 6
elif x > 56000 and y > 60000 and x < 68000 and y < 73000:
return 7
elif x > 56000 and y > 38000 and x < 68000 and y < 49000:
return 8
elif x > 56000 and y > 13000 and x < 68000 and y < 23000:
return 9
return 0
def __GetDevilBase(self, x, y):
if x > 3000 and y > 4500 and x < 45000 and y < 45000:
return 1
elif x > 54000 and y > 3900 and x < 100000 and y < 46200:
return 2
elif x > 104800 and y > 3500 and x < 145500 and y < 45800:
return 3
elif x > 3100 and y > 54100 and x < 56400 and y < 105800:
return 4
elif x > 65000 and y > 54000 and x < 105000 and y < 95500:
return 5
elif x > 117500 and y > 57600 and x < 142000 and y < 81000:
return 6
elif x > 5000 and y > 104900 and x < 15000 and y < 122000:
return 7
return 0
def ShowMapName(self, mapName, x, y):
if mapName not in _MAP_NAME_SUFFIXES:
print((" [ERROR] - There is no map name image", mapName))
return
try:
self.LoadImage(LOCALE_PATH + _MAP_NAME_SUFFIXES[mapName])
except RuntimeError:
return
self.__Initialize()
if mapName == "metin2_map_deviltower1":
self.SetPosition(-60, 80)
self.floorImage = ui.ExpandedImageBox()
self.floorImage.AddFlag("not_pick")
self.floorImage.SetWindowHorizontalAlignCenter()
self.floorImage.SetPosition(100, 80)
self.floorImage.SetAlpha(0.0)
self.floorImage.Show()
try:
floor = self.__GetDevilTowerFloor(x, y)
print((x, y, floor))
self.floorImage.LoadImage(LOCALE_PATH+"devil1_%df.tga" % floor)
except RuntimeError:
self.SetPosition(0, 80)
self.floorImage.Hide()
self.floorImage = None
if mapName == "metin2_map_devilsCatacomb":
self.SetPosition(-75, 80)
self.floorImage = ui.ExpandedImageBox()
self.floorImage.AddFlag("not_pick")
self.floorImage.SetWindowHorizontalAlignCenter()
self.floorImage.SetPosition(100, 80)
self.floorImage.SetAlpha(0.0)
self.floorImage.Show()
try:
floor = self.__GetDevilBase(x, y)
print((x, y, floor))
self.floorImage.LoadImage(LOCALE_PATH+"devil1_%df.tga" % floor)
except RuntimeError:
self.SetPosition(0, 80)
self.floorImage.Hide()
self.floorImage = None
self.state = self.STATE_FADE_IN
self.fadeStartTime = app.GetTime() + 1.0
self.Show()
def Update(self):
self.SetAlpha(self.curAlpha)
if self.floorImage:
self.floorImage.SetAlpha(self.curAlpha)
if self.objectiveImage:
self.objectiveImage.SetAlpha(self.curAlpha)
if self.STATE_FADE_IN == self.state:
if app.GetTime() > self.fadeStartTime:
self.curAlpha += 0.05
if self.curAlpha > 0.9:
self.state = self.STATE_SHOW
self.fadeStartTime = app.GetTime() + 5.0
elif self.STATE_SHOW == self.state:
if app.GetTime() > self.fadeStartTime:
self.state = self.STATE_FADE_OUT
elif self.STATE_FADE_OUT == self.state:
self.curAlpha -= 0.05
if self.curAlpha < 0.0001:
self.Hide()
if self.floorImage:
self.floorImage.Hide()
self.floorImage = None
if self.objectiveImage:
self.objectiveImage.Hide()
self.objectiveImage = None
return
-739
View File
@@ -1,739 +0,0 @@
import app
import ui
import grp
import net
import guild
import messenger
import localeInfo
import constInfo
import uiToolTip
import uiCommon
from _weakref import proxy
FRIEND = 0
GUILD = 1
class MessengerItem(ui.Window):
def __init__(self, getParentEvent):
ui.Window.__init__(self)
self.SetParent(getParentEvent())
self.AddFlag("float")
self.name = ""
self.image = ui.ImageBox()
self.image.AddFlag("not_pick")
self.image.SetParent(self)
self.image.Show()
self.text = ui.TextLine()
self.text.SetParent(self)
self.text.SetPosition(20, 2)
self.text.Show()
self.lovePoint = -1
self.lovePointToolTip = None
self.isSelected = False
self.getParentEvent = getParentEvent
def SetName(self, name):
self.name = name
if name:
self.text.SetText(name)
self.SetSize(20 + 6*len(name) + 4, 16)
if app.IsRTL():
self.text.SetPosition(20 + 6*len(name) + 4, 2)
def SetLovePoint(self, lovePoint):
self.lovePoint = lovePoint
def Select(self):
self.isSelected = True
def UnSelect(self):
self.isSelected = False
def GetName(self):
return self.name
def GetStepWidth(self):
return 0
# Whisper
def CanWhisper(self):
return False
def IsOnline(self):
return False
def OnWhisper(self):
pass
# Remove
def CanRemove(self):
return False
def OnRemove(self):
return False
# Warp
def CanWarp(self):
return False
def OnWarp(self):
pass
def OnMouseOverIn(self):
if -1 != self.lovePoint:
if not self.lovePointToolTip:
self.lovePointToolTip = uiToolTip.ToolTip(100)
self.lovePointToolTip.SetTitle(self.name)
self.lovePointToolTip.AppendTextLine(localeInfo.AFF_LOVE_POINT % (self.lovePoint))
self.lovePointToolTip.ResizeToolTip()
self.lovePointToolTip.ShowToolTip()
def OnMouseOverOut(self):
if self.lovePointToolTip:
self.lovePointToolTip.HideToolTip()
def OnMouseLeftButtonDown(self):
self.getParentEvent().OnSelectItem(self)
def OnMouseLeftButtonDoubleClick(self):
self.getParentEvent().OnDoubleClickItem(self)
def OnRender(self):
if self.isSelected:
x, y = self.GetGlobalPosition()
grp.SetColor(grp.GenerateColor(0.0, 0.0, 0.7, 0.7))
grp.RenderBar(x + 16, y, self.GetWidth() - 16, self.GetHeight())
class MessengerMemberItem(MessengerItem):
STATE_OFFLINE = 0
STATE_ONLINE = 1
IMAGE_FILE_NAME = { "ONLINE" : "d:/ymir work/ui/game/windows/messenger_list_online.sub",
"OFFLINE" : "d:/ymir work/ui/game/windows/messenger_list_offline.sub", }
def __init__(self, getParentEvent):
MessengerItem.__init__(self, getParentEvent)
self.key = None
self.state = self.STATE_OFFLINE
self.Offline()
@property
def RemoveMessage(self):
return localeInfo.MESSENGER_DO_YOU_DELETE
def GetStepWidth(self):
return 15
def SetKey(self, key):
self.key = key
def IsSameKey(self, key):
return self.key == key
def IsOnline(self):
if self.STATE_ONLINE == self.state:
return True
return False
def Online(self):
self.image.LoadImage(self.IMAGE_FILE_NAME["ONLINE"])
self.state = self.STATE_ONLINE
def Offline(self):
self.image.LoadImage(self.IMAGE_FILE_NAME["OFFLINE"])
self.state = self.STATE_OFFLINE
def CanWhisper(self):
if self.IsOnline():
return True
return False
def OnWhisper(self):
if self.IsOnline():
self.getParentEvent().whisperButtonEvent(self.GetName())
def Select(self):
MessengerItem.Select(self)
class MessengerGroupItem(MessengerItem):
IMAGE_FILE_NAME = { "OPEN" : "d:/ymir work/ui/game/windows/messenger_list_open.sub",
"CLOSE" : "d:/ymir work/ui/game/windows/messenger_list_close.sub", }
def __init__(self, getParentEvent):
self.isOpen = False
self.memberList = []
MessengerItem.__init__(self, getParentEvent)
def AppendMember(self, member, key, name):
member.SetKey(key)
member.SetName(name)
self.memberList.append(member)
return member
def RemoveMember(self, item):
for i in range(len(self.memberList)):
if item == self.memberList[i]:
del self.memberList[i]
return
def ClearMember(self):
self.memberList = []
def FindMember(self, key):
return next((m for m in self.memberList if m.IsSameKey(key)), None)
def GetLoginMemberList(self):
return list(filter(MessengerMemberItem.IsOnline, self.memberList))
def GetLogoutMemberList(self):
return [arg for arg in self.memberList if not arg.IsOnline()]
def IsOpen(self):
return self.isOpen
def Open(self):
self.image.LoadImage(self.IMAGE_FILE_NAME["OPEN"])
self.isOpen = True
def Close(self):
self.image.LoadImage(self.IMAGE_FILE_NAME["CLOSE"])
self.isOpen = False
list(map(ui.Window.Hide, self.memberList))
def Select(self):
if self.IsOpen():
self.Close()
else:
self.Open()
MessengerItem.Select(self)
self.getParentEvent().OnRefreshList()
class MessengerFriendItem(MessengerMemberItem):
def __init__(self, getParentEvent):
MessengerMemberItem.__init__(self, getParentEvent)
def CanRemove(self):
return True
def OnRemove(self):
messenger.RemoveFriend(self.key)
net.SendMessengerRemovePacket(self.key, self.name)
return True
class MessengerGuildItem(MessengerMemberItem):
def __init__(self, getParentEvent):
MessengerMemberItem.__init__(self, getParentEvent)
def CanWarp(self):
if not self.IsOnline():
return False
return True
def OnWarp(self):
net.SendGuildUseSkillPacket(155, self.key)
@property
def RemoveMessage(self):
return localeInfo.GUILD_REMOVE_MEMBER_QUESTION
def CanRemove(self):
for i in range(guild.ENEMY_GUILD_SLOT_MAX_COUNT):
if guild.GetEnemyGuildName(i) != "":
return False
if guild.MainPlayerHasAuthority(guild.AUTH_REMOVE_MEMBER):
guildMasterName = guild.GetGuildMasterName()
isTargetGuildMaster = guildMasterName == self.name
if guild.IsMemberByName(self.name) and not isTargetGuildMaster:
return True
return False
def OnRemove(self):
net.SendGuildRemoveMemberPacket(self.key)
return True
class MessengerFriendGroup(MessengerGroupItem):
def __init__(self, getParentEvent):
MessengerGroupItem.__init__(self, getParentEvent)
self.SetName(localeInfo.MESSENGER_FRIEND)
def AppendMember(self, key, name):
item = MessengerFriendItem(self.getParentEvent)
return MessengerGroupItem.AppendMember(self, item, key, name)
class MessengerGuildGroup(MessengerGroupItem):
def __init__(self, getParentEvent):
MessengerGroupItem.__init__(self, getParentEvent)
self.SetName(localeInfo.MESSENGER_GUILD)
self.AddFlag("float")
def AppendMember(self, key, name):
item = MessengerGuildItem(self.getParentEvent)
return MessengerGroupItem.AppendMember(self, item, key, name)
class MessengerFamilyGroup(MessengerGroupItem):
def __init__(self, getParentEvent):
MessengerGroupItem.__init__(self, getParentEvent)
self.SetName(localeInfo.MESSENGER_FAMILY)
self.AddFlag("float")
self.lover = None
def AppendMember(self, key, name):
item = MessengerGuildItem(self.getParentEvent)
self.lover = item
return MessengerGroupItem.AppendMember(self, item, key, name)
def GetLover(self):
return self.lover
###################################################################################################
###################################################################################################
###################################################################################################
class MessengerWindow(ui.ScriptWindow):
START_POSITION = 40
class ResizeButton(ui.DragButton):
def OnMouseOverIn(self):
app.SetCursor(app.VSIZE)
def OnMouseOverOut(self):
app.SetCursor(app.NORMAL)
def __init__(self):
ui.ScriptWindow.__init__(self)
messenger.SetMessengerHandler(self)
self.board = None
self.groupList = []
self.showingItemList = []
self.selectedItem = None
self.whisperButtonEvent = lambda *arg: None
self.familyGroup = None
self.guildButtonEvent = None
self.showingPageSize = 0
self.startLine = 0
self.isLoaded = 0
self.__AddGroup()
messenger.RefreshGuildMember()
def InitializeHandler(self):
"""Load UI and register packet handlers without showing window"""
if self.isLoaded == 0:
self.isLoaded = 1
self.__LoadWindow()
self.OnRefreshList()
self.OnResizeDialog()
def Show(self):
if self.isLoaded==0:
self.isLoaded=1
self.__LoadWindow()
self.OnRefreshList()
self.OnResizeDialog()
ui.ScriptWindow.Show(self)
def __LoadWindow(self):
pyScrLoader = ui.PythonScriptLoader()
pyScrLoader.LoadScriptFile(self, "UIScript/MessengerWindow.py")
try:
self.board = self.GetChild("board")
self.scrollBar = self.GetChild("ScrollBar")
self.whisperButton = self.GetChild("WhisperButton")
self.removeButton = self.GetChild("RemoveButton")
self.addFriendButton = self.GetChild("AddFriendButton")
self.guildButton = self.GetChild("GuildButton")
except:
import exception
exception.Abort("MessengerWindow.__LoadWindow.__Bind")
self.board.SetCloseEvent(ui.__mem_func__(self.Close))
self.scrollBar.SetScrollEvent(ui.__mem_func__(self.OnScroll))
self.whisperButton.SetEvent(ui.__mem_func__(self.OnPressWhisperButton))
self.removeButton.SetEvent(ui.__mem_func__(self.OnPressRemoveButton))
self.addFriendButton.SetEvent(ui.__mem_func__(self.OnPressAddFriendButton))
self.guildButton.SetEvent(ui.__mem_func__(self.OnPressGuildButton))
self.whisperButton.Disable()
self.removeButton.Disable()
resizeButton = self.ResizeButton()
resizeButton.AddFlag("restrict_x")
resizeButton.SetParent(self)
resizeButton.SetSize(self.GetWidth(), 10)
resizeButton.SetWindowVerticalAlignBottom()
resizeButton.SetPosition(0, 0)
resizeButton.Show()
self.resizeButton = resizeButton
self.resizeButton.SetMoveEvent(ui.__mem_func__(self.OnResizeDialog))
self.resizeButton.SetPosition(0, 300)
for list in self.groupList:
list.SetTop()
def __del__(self):
messenger.SetMessengerHandler(None)
ui.ScriptWindow.__del__(self)
def Destroy(self):
self.board = None
self.scrollBar = None
self.resizeButton = None
self.friendNameBoard = None
self.questionDialog = None
self.popupDialog = None
self.inputDialog = None
self.familyGroup = None
self.whisperButton = None
self.removeButton = None
def OnCloseQuestionDialog(self):
self.questionDialog.Close()
self.questionDialog = None
return True
def Close(self):
self.questionDialog = None
self.Hide()
def SetSize(self, width, height):
ui.ScriptWindow.SetSize(self, width, height)
if self.board:
self.board.SetSize(width, height)
def OnResizeDialog(self):
x, y = self.resizeButton.GetLocalPosition()
if y < 140:
self.resizeButton.SetPosition(x, 140)
return
self.SetSize(self.GetWidth(), y + self.resizeButton.GetHeight())
self.showingPageSize = y - (self.START_POSITION + 26)
self.scrollBar.SetScrollBarSize(self.showingPageSize)
self.__LocateMember()
self.resizeButton.TurnOffCallBack()
self.UpdateRect()
self.resizeButton.TurnOnCallBack()
def __LocateMember(self):
if self.isLoaded==0:
return
if self.showingPageSize / 20 >= len(self.showingItemList):
self.scrollBar.Hide()
self.startLine = 0
else:
if self.showingItemList:
self.scrollBar.SetMiddleBarSize(float(self.showingPageSize / 20) / float(len(self.showingItemList)))
self.scrollBar.Show()
#####
yPos = self.START_POSITION
heightLimit = self.GetHeight() - (self.START_POSITION + 13)
list(map(ui.Window.Hide, self.showingItemList))
for item in self.showingItemList[self.startLine:]:
item.SetPosition(20 + item.GetStepWidth(), yPos)
item.SetTop()
item.Show()
yPos += 20
if yPos > heightLimit:
break
def __AddGroup(self):
member = MessengerFriendGroup(ui.__mem_func__(self.GetSelf))
member.Open()
member.Show()
self.groupList.append(member)
member = MessengerGuildGroup(ui.__mem_func__(self.GetSelf))
member.Open()
member.Show()
self.groupList.append(member)
def __AddFamilyGroup(self):
member = MessengerFamilyGroup(ui.__mem_func__(self.GetSelf))
member.Open()
member.Show()
self.familyGroup = member
def ClearGuildMember(self):
self.groupList[GUILD].ClearMember()
def SetWhisperButtonEvent(self, event):
self.whisperButtonEvent=event
def SetGuildButtonEvent(self, event):
self.guildButtonEvent=event
def OnPressGuildButton(self):
self.guildButtonEvent()
def OnPressAddFriendButton(self):
friendNameBoard = uiCommon.InputDialog()
friendNameBoard.SetTitle(localeInfo.MESSENGER_ADD_FRIEND)
friendNameBoard.SetAcceptEvent(ui.__mem_func__(self.OnAddFriend))
friendNameBoard.SetCancelEvent(ui.__mem_func__(self.OnCancelAddFriend))
friendNameBoard.Open()
self.friendNameBoard = friendNameBoard
def OnAddFriend(self):
text = self.friendNameBoard.GetText()
if text:
net.SendMessengerAddByNamePacket(text)
self.friendNameBoard.Close()
self.friendNameBoard = None
return True
def OnCancelAddFriend(self):
self.friendNameBoard.Close()
self.friendNameBoard = None
return True
def OnPressWhisperButton(self):
if self.selectedItem:
self.selectedItem.OnWhisper()
def OnPressRemoveButton(self):
if self.selectedItem:
if self.selectedItem.CanRemove():
self.questionDialog = uiCommon.QuestionDialog()
self.questionDialog.SetText(self.selectedItem.RemoveMessage)
self.questionDialog.SetAcceptEvent(ui.__mem_func__(self.OnRemove))
self.questionDialog.SetCancelEvent(ui.__mem_func__(self.OnCloseQuestionDialog))
self.questionDialog.Open()
def OnRemove(self):
if self.selectedItem:
if self.selectedItem.CanRemove():
list(map(lambda arg, argDeletingItem=self.selectedItem: arg.RemoveMember(argDeletingItem), self.groupList))
self.selectedItem.OnRemove()
self.selectedItem.UnSelect()
self.selectedItem = None
self.whisperButton.Disable()
self.removeButton.Disable()
self.OnRefreshList()
self.OnCloseQuestionDialog()
def OnScroll(self):
scrollLineCount = len(self.showingItemList) - (self.showingPageSize / 20)
startLine = int(scrollLineCount * self.scrollBar.GetPos())
if startLine != self.startLine:
self.startLine = startLine
self.__LocateMember()
def OnPressEscapeKey(self):
self.Close()
return True
## CallBack
def OnSelectItem(self, item):
if self.selectedItem:
if item != self.selectedItem:
self.selectedItem.UnSelect()
self.selectedItem = item
if self.selectedItem:
self.selectedItem.Select()
if self.selectedItem.CanWhisper():
self.whisperButton.Enable()
else:
self.whisperButton.Disable()
if self.selectedItem.CanRemove():
self.removeButton.Enable()
else:
self.removeButton.Disable()
def OnDoubleClickItem(self, item):
if not self.selectedItem:
return
if self.selectedItem.IsOnline():
self.OnPressWhisperButton()
def GetSelf(self):
return self
def OnRefreshList(self):
self.showingItemList = []
if self.familyGroup:
self.showingItemList.append(self.familyGroup)
if self.familyGroup.GetLover():
self.showingItemList.append(self.familyGroup.GetLover())
for group in self.groupList:
self.showingItemList.append(group)
if group.IsOpen():
loginMemberList = group.GetLoginMemberList()
logoutMemberList = group.GetLogoutMemberList()
if loginMemberList or logoutMemberList:
for member in loginMemberList:
self.showingItemList.append(member)
for member in logoutMemberList:
self.showingItemList.append(member)
else:
item = MessengerItem(ui.__mem_func__(self.GetSelf))
item.SetName(localeInfo.MESSENGER_EMPTY_LIST)
self.showingItemList.append(item)
self.__LocateMember()
def RefreshMessenger(self):
self.OnRefreshList()
## EventHandler
def __AddList(self, groupIndex, key, name):
group = self.groupList[groupIndex]
member = group.FindMember(key)
if not member:
member = group.AppendMember(key, name)
self.OnSelectItem(None)
return member
def OnRemoveList(self, groupIndex, key):
group = self.groupList[groupIndex]
member = group.FindMember(key)
if not member:
return
if self.selectedItem is member or member.IsSameKey(key):
member.UnSelect()
self.selectedItem = None
# Optional: also disable buttons to mirror local delete flow
self.whisperButton.Disable()
self.removeButton.Disable()
member.Hide()
group.RemoveMember(member)
self.OnRefreshList()
def OnRemoveAllList(self, groupIndex):
group = self.groupList[groupIndex]
group.ClearMember()
self.OnRefreshList()
def OnLogin(self, groupIndex, key, name=None):
if not name:
name = key
group = self.groupList[groupIndex]
member = self.__AddList(groupIndex, key, name)
member.SetName(name)
member.Online()
self.OnRefreshList()
def OnLogout(self, groupIndex, key, name=None):
group = self.groupList[groupIndex]
member = self.__AddList(groupIndex, key, name)
if not name:
name = key
member.SetName(name)
member.Offline()
self.OnRefreshList()
def OnAddLover(self, name, lovePoint):
if not self.familyGroup:
self.__AddFamilyGroup()
member = self.familyGroup.AppendMember(0, name)
member.SetName(name)
member.SetLovePoint(lovePoint)
member.Offline()
self.OnRefreshList()
def OnUpdateLovePoint(self, lovePoint):
if not self.familyGroup:
return
lover = self.familyGroup.GetLover()
if not lover:
return
lover.SetLovePoint(lovePoint)
def OnLoginLover(self):
if not self.familyGroup:
return
lover = self.familyGroup.GetLover()
if not lover:
return
lover.Online()
def OnLogoutLover(self):
if not self.familyGroup:
return
lover = self.familyGroup.GetLover()
if not lover:
return
lover.Offline()
def ClearLoverInfo(self):
if not self.familyGroup:
return
self.familyGroup.ClearMember()
self.familyGroup = None
self.OnRefreshList()
-487
View File
@@ -1,487 +0,0 @@
import ui
import uiScriptLocale
import wndMgr
import player
import miniMap
import localeInfo
import net
import app
import colorInfo
import constInfo
import background
class MapTextToolTip(ui.Window):
def __init__(self):
ui.Window.__init__(self)
textLine = ui.TextLine()
textLine.SetParent(self)
textLine.SetHorizontalAlignCenter()
textLine.SetOutline()
textLine.SetHorizontalAlignRight()
textLine.Show()
self.textLine = textLine
def __del__(self):
ui.Window.__del__(self)
def SetText(self, text):
self.textLine.SetText(text)
def SetTooltipPosition(self, PosX, PosY):
if app.IsRTL():
w, h = self.textLine.GetTextSize()
self.textLine.SetPosition(PosX - w - 5, PosY)
else:
self.textLine.SetPosition(PosX - 5, PosY)
def SetTextColor(self, TextColor):
self.textLine.SetPackedFontColor(TextColor)
def GetTextSize(self):
return self.textLine.GetTextSize()
class AtlasWindow(ui.ScriptWindow):
class AtlasRenderer(ui.Window):
def __init__(self):
ui.Window.__init__(self)
self.AddFlag("not_pick")
def OnUpdate(self):
miniMap.UpdateAtlas()
def OnRender(self):
(x, y) = self.GetGlobalPosition()
fx = float(x)
fy = float(y)
miniMap.RenderAtlas(fx, fy)
def HideAtlas(self):
miniMap.HideAtlas()
def ShowAtlas(self):
miniMap.ShowAtlas()
def __init__(self):
self.tooltipInfo = MapTextToolTip()
self.tooltipInfo.Hide()
self.infoGuildMark = ui.MarkBox()
self.infoGuildMark.Hide()
self.AtlasMainWindow = None
self.mapName = ""
self.board = 0
ui.ScriptWindow.__init__(self)
def __del__(self):
ui.ScriptWindow.__del__(self)
def SetMapName(self, mapName):
self.board.SetTitleName(localeInfo.MINIMAP_ZONE_NAME_DICT[mapName])
def LoadWindow(self):
try:
pyScrLoader = ui.PythonScriptLoader()
pyScrLoader.LoadScriptFile(self, "UIScript/AtlasWindow.py")
except:
import exception
exception.Abort("AtlasWindow.LoadWindow.LoadScript")
try:
self.board = self.GetChild("board")
except:
import exception
exception.Abort("AtlasWindow.LoadWindow.BindObject")
self.AtlasMainWindow = self.AtlasRenderer()
self.board.SetCloseEvent(self.Hide)
self.AtlasMainWindow.SetParent(self.board)
self.AtlasMainWindow.SetPosition(7, 30)
self.tooltipInfo.SetParent(self.board)
self.infoGuildMark.SetParent(self.board)
self.SetPosition(wndMgr.GetScreenWidth() - 136 - 256 - 10, 0)
self.Hide()
miniMap.RegisterAtlasWindow(self)
def Destroy(self):
miniMap.UnregisterAtlasWindow()
self.ClearDictionary()
self.AtlasMainWindow = None
self.tooltipAtlasClose = 0
self.tooltipInfo = None
self.infoGuildMark = None
self.board = None
def OnUpdate(self):
if not self.tooltipInfo:
return
if not self.infoGuildMark:
return
self.infoGuildMark.Hide()
self.tooltipInfo.Hide()
if False == self.board.IsIn():
return
(mouseX, mouseY) = wndMgr.GetMousePosition()
(bFind, sName, iPosX, iPosY, dwTextColor, dwGuildID) = miniMap.GetAtlasInfo(mouseX, mouseY)
if False == bFind:
return
if "empty_guild_area" == sName:
sName = localeInfo.GUILD_EMPTY_AREA
if app.IsRTL() and sName[-1].isalnum():
self.tooltipInfo.SetText("(%s)%d, %d" % (sName, iPosX, iPosY))
else:
self.tooltipInfo.SetText("%s(%d, %d)" % (sName, iPosX, iPosY))
(x, y) = self.GetGlobalPosition()
self.tooltipInfo.SetTooltipPosition(mouseX - x, mouseY - y)
self.tooltipInfo.SetTextColor(dwTextColor)
self.tooltipInfo.Show()
self.tooltipInfo.SetTop()
if 0 != dwGuildID:
textWidth, textHeight = self.tooltipInfo.GetTextSize()
self.infoGuildMark.SetIndex(dwGuildID)
self.infoGuildMark.SetPosition(mouseX - x - textWidth - 18 - 5, mouseY - y)
self.infoGuildMark.Show()
def Hide(self):
if self.AtlasMainWindow:
self.AtlasMainWindow.HideAtlas()
self.AtlasMainWindow.Hide()
ui.ScriptWindow.Hide(self)
def Show(self):
if self.AtlasMainWindow:
(bGet, iSizeX, iSizeY) = miniMap.GetAtlasSize()
if bGet:
self.SetSize(iSizeX + 15, iSizeY + 38)
if app.IsRTL():
self.board.SetPosition(iSizeX+15, 0)
self.board.SetSize(iSizeX + 15, iSizeY + 38)
#self.AtlasMainWindow.SetSize(iSizeX, iSizeY)
self.AtlasMainWindow.ShowAtlas()
self.AtlasMainWindow.Show()
ui.ScriptWindow.Show(self)
def SetCenterPositionAdjust(self, x, y):
self.SetPosition((wndMgr.GetScreenWidth() - self.GetWidth()) // 2 + x, (wndMgr.GetScreenHeight() - self.GetHeight()) // 2 + y)
def OnPressEscapeKey(self):
self.Hide()
return True
def __RegisterMiniMapColor(type, rgb):
miniMap.RegisterColor(type, rgb[0], rgb[1], rgb[2])
class MiniMap(ui.ScriptWindow):
CANNOT_SEE_INFO_MAP_DICT = {
"metin2_map_monkeydungeon" : False,
"metin2_map_monkeydungeon_02" : False,
"metin2_map_monkeydungeon_03" : False,
"metin2_map_devilsCatacomb" : False,
}
def __init__(self):
ui.ScriptWindow.__init__(self)
self.__Initialize()
miniMap.Create()
miniMap.SetScale(2.0)
self.AtlasWindow = AtlasWindow()
self.AtlasWindow.LoadWindow()
self.AtlasWindow.Hide()
self.tooltipMiniMapOpen = MapTextToolTip()
self.tooltipMiniMapOpen.SetText(localeInfo.MINIMAP)
self.tooltipMiniMapOpen.Show()
self.tooltipMiniMapClose = MapTextToolTip()
self.tooltipMiniMapClose.SetText(localeInfo.UI_CLOSE)
self.tooltipMiniMapClose.Show()
self.tooltipScaleUp = MapTextToolTip()
self.tooltipScaleUp.SetText(localeInfo.MINIMAP_INC_SCALE)
self.tooltipScaleUp.Show()
self.tooltipScaleDown = MapTextToolTip()
self.tooltipScaleDown.SetText(localeInfo.MINIMAP_DEC_SCALE)
self.tooltipScaleDown.Show()
self.tooltipAtlasOpen = MapTextToolTip()
self.tooltipAtlasOpen.SetText(localeInfo.MINIMAP_SHOW_AREAMAP)
self.tooltipAtlasOpen.Show()
self.tooltipInfo = MapTextToolTip()
self.tooltipInfo.Show()
if miniMap.IsAtlas():
self.tooltipAtlasOpen.SetText(localeInfo.MINIMAP_SHOW_AREAMAP)
else:
self.tooltipAtlasOpen.SetText(localeInfo.MINIMAP_CAN_NOT_SHOW_AREAMAP)
self.tooltipInfo = MapTextToolTip()
self.tooltipInfo.Show()
self.mapName = ""
self.isLoaded = 0
self.canSeeInfo = True
# AUTOBAN
self.imprisonmentDuration = 0
self.imprisonmentEndTime = 0
self.imprisonmentEndTimeText = ""
# END_OF_AUTOBAN
def __del__(self):
miniMap.Destroy()
ui.ScriptWindow.__del__(self)
def __Initialize(self):
self.positionInfo = 0
self.observerCount = 0
self.OpenWindow = 0
self.CloseWindow = 0
self.ScaleUpButton = 0
self.ScaleDownButton = 0
self.MiniMapHideButton = 0
self.MiniMapShowButton = 0
self.AtlasShowButton = 0
self.tooltipMiniMapOpen = 0
self.tooltipMiniMapClose = 0
self.tooltipScaleUp = 0
self.tooltipScaleDown = 0
self.tooltipAtlasOpen = 0
self.tooltipInfo = None
self.serverInfo = None
def SetMapName(self, mapName):
self.mapName=mapName
self.AtlasWindow.SetMapName(mapName)
if mapName in self.CANNOT_SEE_INFO_MAP_DICT:
self.canSeeInfo = False
self.HideMiniMap()
self.tooltipMiniMapOpen.SetText(localeInfo.MINIMAP_CANNOT_SEE)
else:
self.canSeeInfo = True
self.ShowMiniMap()
self.tooltipMiniMapOpen.SetText(localeInfo.MINIMAP)
# AUTOBAN
def SetImprisonmentDuration(self, duration):
self.imprisonmentDuration = duration
self.imprisonmentEndTime = app.GetGlobalTimeStamp() + duration
self.__UpdateImprisonmentDurationText()
def __UpdateImprisonmentDurationText(self):
restTime = max(self.imprisonmentEndTime - app.GetGlobalTimeStamp(), 0)
imprisonmentEndTimeText = localeInfo.SecondToDHM(restTime)
if imprisonmentEndTimeText != self.imprisonmentEndTimeText:
self.imprisonmentEndTimeText = imprisonmentEndTimeText
self.serverInfo.SetText("%s: %s" % (uiScriptLocale.AUTOBAN_QUIZ_REST_TIME, self.imprisonmentEndTimeText))
# END_OF_AUTOBAN
def Show(self):
self.__LoadWindow()
ui.ScriptWindow.Show(self)
def __LoadWindow(self):
if self.isLoaded == 1:
return
self.isLoaded = 1
try:
pyScrLoader = ui.PythonScriptLoader()
if app.IsRTL():
pyScrLoader.LoadScriptFile(self, uiScriptLocale.LOCALE_UISCRIPT_PATH + "Minimap.py")
else:
pyScrLoader.LoadScriptFile(self, "UIScript/MiniMap.py")
except:
import exception
exception.Abort("MiniMap.LoadWindow.LoadScript")
try:
self.OpenWindow = self.GetChild("OpenWindow")
self.MiniMapWindow = self.GetChild("MiniMapWindow")
self.ScaleUpButton = self.GetChild("ScaleUpButton")
self.ScaleDownButton = self.GetChild("ScaleDownButton")
self.MiniMapHideButton = self.GetChild("MiniMapHideButton")
self.AtlasShowButton = self.GetChild("AtlasShowButton")
self.CloseWindow = self.GetChild("CloseWindow")
self.MiniMapShowButton = self.GetChild("MiniMapShowButton")
self.positionInfo = self.GetChild("PositionInfo")
self.observerCount = self.GetChild("ObserverCount")
self.serverInfo = self.GetChild("ServerInfo")
except:
import exception
exception.Abort("MiniMap.LoadWindow.Bind")
if constInfo.MINIMAP_POSITIONINFO_ENABLE==0:
self.positionInfo.Hide()
self.serverInfo.SetText(net.GetServerInfo())
self.ScaleUpButton.SetEvent(ui.__mem_func__(self.ScaleUp))
self.ScaleDownButton.SetEvent(ui.__mem_func__(self.ScaleDown))
self.MiniMapHideButton.SetEvent(ui.__mem_func__(self.HideMiniMap))
self.MiniMapShowButton.SetEvent(ui.__mem_func__(self.ShowMiniMap))
if miniMap.IsAtlas():
self.AtlasShowButton.SetEvent(ui.__mem_func__(self.ShowAtlas))
(ButtonPosX, ButtonPosY) = self.MiniMapShowButton.GetGlobalPosition()
self.tooltipMiniMapOpen.SetTooltipPosition(ButtonPosX, ButtonPosY)
(ButtonPosX, ButtonPosY) = self.MiniMapHideButton.GetGlobalPosition()
self.tooltipMiniMapClose.SetTooltipPosition(ButtonPosX, ButtonPosY)
(ButtonPosX, ButtonPosY) = self.ScaleUpButton.GetGlobalPosition()
self.tooltipScaleUp.SetTooltipPosition(ButtonPosX, ButtonPosY)
(ButtonPosX, ButtonPosY) = self.ScaleDownButton.GetGlobalPosition()
self.tooltipScaleDown.SetTooltipPosition(ButtonPosX, ButtonPosY)
(ButtonPosX, ButtonPosY) = self.AtlasShowButton.GetGlobalPosition()
self.tooltipAtlasOpen.SetTooltipPosition(ButtonPosX, ButtonPosY)
self.ShowMiniMap()
def Destroy(self):
self.HideMiniMap()
self.AtlasWindow.Destroy()
self.AtlasWindow = None
self.ClearDictionary()
self.__Initialize()
def UpdateObserverCount(self, observerCount):
if observerCount>0:
self.observerCount.Show()
elif observerCount<=0:
self.observerCount.Hide()
self.observerCount.SetText(localeInfo.MINIMAP_OBSERVER_COUNT % observerCount)
def OnUpdate(self):
(x, y, z) = player.GetMainCharacterPosition()
miniMap.Update(x, y)
self.positionInfo.SetText("(%.0f, %.0f)" % (x // 100, y // 100))
if self.tooltipInfo:
if True == self.MiniMapWindow.IsIn():
(mouseX, mouseY) = wndMgr.GetMousePosition()
(bFind, sName, iPosX, iPosY, dwTextColor) = miniMap.GetInfo(mouseX, mouseY)
if bFind == 0:
self.tooltipInfo.Hide()
elif not self.canSeeInfo:
self.tooltipInfo.SetText("%s (%s)" % (sName, localeInfo.UI_POS_UNKNOWN))
self.tooltipInfo.SetTooltipPosition(mouseX - 5, mouseY)
self.tooltipInfo.SetTextColor(dwTextColor)
self.tooltipInfo.Show()
else:
if app.IsRTL() and sName[-1].isalnum():
self.tooltipInfo.SetText("(%s) %d, %d" % (sName, iPosX, iPosY))
else:
self.tooltipInfo.SetText("%s (%d, %d)" % (sName, iPosX, iPosY))
self.tooltipInfo.SetTooltipPosition(mouseX - 5, mouseY)
self.tooltipInfo.SetTextColor(dwTextColor)
self.tooltipInfo.Show()
else:
self.tooltipInfo.Hide()
# AUTOBAN
if self.imprisonmentDuration:
self.__UpdateImprisonmentDurationText()
# END_OF_AUTOBAN
if True == self.MiniMapShowButton.IsIn():
self.tooltipMiniMapOpen.Show()
else:
self.tooltipMiniMapOpen.Hide()
if True == self.MiniMapHideButton.IsIn():
self.tooltipMiniMapClose.Show()
else:
self.tooltipMiniMapClose.Hide()
if True == self.ScaleUpButton.IsIn():
self.tooltipScaleUp.Show()
else:
self.tooltipScaleUp.Hide()
if True == self.ScaleDownButton.IsIn():
self.tooltipScaleDown.Show()
else:
self.tooltipScaleDown.Hide()
if True == self.AtlasShowButton.IsIn():
self.tooltipAtlasOpen.Show()
else:
self.tooltipAtlasOpen.Hide()
def OnRender(self):
(x, y) = self.GetGlobalPosition()
fx = float(x)
fy = float(y)
miniMap.Render(fx + 4.0, fy + 5.0)
def Close(self):
self.HideMiniMap()
def HideMiniMap(self):
miniMap.Hide()
self.OpenWindow.Hide()
self.CloseWindow.Show()
def ShowMiniMap(self):
if not self.canSeeInfo:
return
miniMap.Show()
self.OpenWindow.Show()
self.CloseWindow.Hide()
def isShowMiniMap(self):
return miniMap.isShow()
def ScaleUp(self):
miniMap.ScaleUp()
def ScaleDown(self):
miniMap.ScaleDown()
def ShowAtlas(self):
if not miniMap.IsAtlas():
return
if not self.AtlasWindow.IsShow():
self.AtlasWindow.Show()
def ToggleAtlasWindow(self):
if not miniMap.IsAtlas():
return
if self.AtlasWindow.IsShow():
self.AtlasWindow.Hide()
else:
self.AtlasWindow.Show()
-325
View File
@@ -1,325 +0,0 @@
import ui
import snd
import systemSetting
import net
import chat
import app
import localeInfo
import constInfo
import chrmgr
import player
blockMode = 0
class OptionDialog(ui.ScriptWindow):
def __init__(self):
ui.ScriptWindow.__init__(self)
self.__Initialize()
self.__LoadDialog()
def __del__(self):
ui.ScriptWindow.__del__(self)
print(" -------------------------------------- DELETE OPTION DIALOG")
def __Initialize(self):
self.titleBar = 0
self.ctrlMusicVolume = 0
self.ctrlSoundVolume = 0
self.nameColorModeButtonList = []
self.viewTargetBoardButtonList = []
self.cameraModeButtonList = []
self.pvpModeButtonDict = {}
self.fogModeButtonList = []
self.blockButtonList = []
def Destroy(self):
self.ClearDictionary()
self.__Initialize()
print(" -------------------------------------- DESTROY OPTION DIALOG")
def __LoadDialog(self):
try:
pyScriptLoader = ui.PythonScriptLoader()
pyScriptLoader.LoadScriptFile(self, "uiscript/optiondialog.py")
except:
import exception
exception.Abort("OptionDialog.__LoadDialog.LoadObject")
try:
GetObject = self.GetChild
self.titleBar = GetObject("titlebar")
self.ctrlMusicVolume = GetObject("music_volume_controller")
self.ctrlSoundVolume = GetObject("sound_volume_controller")
self.nameColorModeButtonList.append(GetObject("name_color_normal"))
self.nameColorModeButtonList.append(GetObject("name_color_empire"))
self.viewTargetBoardButtonList.append(GetObject("target_board_no_view"))
self.viewTargetBoardButtonList.append(GetObject("target_board_view"))
self.cameraModeButtonList.append(GetObject("camera_short"))
self.cameraModeButtonList.append(GetObject("camera_long"))
self.fogModeButtonList.append(GetObject("fog_level0"))
self.fogModeButtonList.append(GetObject("fog_level1"))
self.fogModeButtonList.append(GetObject("fog_level2"))
self.pvpModeButtonDict[player.PK_MODE_PEACE] = GetObject("pvp_peace")
self.pvpModeButtonDict[player.PK_MODE_REVENGE] = GetObject("pvp_revenge")
self.pvpModeButtonDict[player.PK_MODE_GUILD] = GetObject("pvp_guild")
self.pvpModeButtonDict[player.PK_MODE_FREE] = GetObject("pvp_free")
self.blockButtonList.append(GetObject("block_exchange_button"))
self.blockButtonList.append(GetObject("block_party_button"))
self.blockButtonList.append(GetObject("block_guild_button"))
self.blockButtonList.append(GetObject("block_whisper_button"))
self.blockButtonList.append(GetObject("block_friend_button"))
except:
import exception
exception.Abort("OptionDialog.__LoadDialog.BindObject")
self.SetCenterPosition()
self.ctrlMusicVolume.SetSliderPos(float(systemSetting.GetMusicVolume()))
self.ctrlSoundVolume.SetSliderPos(float(systemSetting.GetSoundVolume()))
self.titleBar.SetCloseEvent(ui.__mem_func__(self.Close))
self.ctrlMusicVolume.SetEvent(ui.__mem_func__(self.OnChangeMusicVolume))
self.ctrlSoundVolume.SetEvent(ui.__mem_func__(self.OnChangeSoundVolume))
self.nameColorModeButtonList[0].SAFE_SetEvent(self.__OnClickNameColorModeNormalButton)
self.nameColorModeButtonList[1].SAFE_SetEvent(self.__OnClickNameColorModeEmpireButton)
self.viewTargetBoardButtonList[0].SAFE_SetEvent(self.__OnClickTargetBoardViewButton)
self.viewTargetBoardButtonList[1].SAFE_SetEvent(self.__OnClickTargetBoardNoViewButton)
self.cameraModeButtonList[0].SAFE_SetEvent(self.__OnClickCameraModeShortButton)
self.cameraModeButtonList[1].SAFE_SetEvent(self.__OnClickCameraModeLongButton)
self.pvpModeButtonDict[player.PK_MODE_PEACE].SAFE_SetEvent(self.__OnClickPvPModePeaceButton)
self.pvpModeButtonDict[player.PK_MODE_REVENGE].SAFE_SetEvent(self.__OnClickPvPModeRevengeButton)
self.pvpModeButtonDict[player.PK_MODE_GUILD].SAFE_SetEvent(self.__OnClickPvPModeGuildButton)
self.pvpModeButtonDict[player.PK_MODE_FREE].SAFE_SetEvent(self.__OnClickPvPModeFreeButton)
self.fogModeButtonList[0].SAFE_SetEvent(self.__OnClickFogModeLevel0Button)
self.fogModeButtonList[1].SAFE_SetEvent(self.__OnClickFogModeLevel1Button)
self.fogModeButtonList[2].SAFE_SetEvent(self.__OnClickFogModeLevel2Button)
self.blockButtonList[0].SetToggleUpEvent(self.__OnClickBlockExchangeButton)
self.blockButtonList[1].SetToggleUpEvent(self.__OnClickBlockPartyButton)
self.blockButtonList[2].SetToggleUpEvent(self.__OnClickBlockGuildButton)
self.blockButtonList[3].SetToggleUpEvent(self.__OnClickBlockWhisperButton)
self.blockButtonList[4].SetToggleUpEvent(self.__OnClickBlockFriendButton)
self.blockButtonList[0].SetToggleDownEvent(self.__OnClickBlockExchangeButton)
self.blockButtonList[1].SetToggleDownEvent(self.__OnClickBlockPartyButton)
self.blockButtonList[2].SetToggleDownEvent(self.__OnClickBlockGuildButton)
self.blockButtonList[3].SetToggleDownEvent(self.__OnClickBlockWhisperButton)
self.blockButtonList[4].SetToggleDownEvent(self.__OnClickBlockFriendButton)
self.__ClickRadioButton(self.fogModeButtonList, constInfo.GET_FOG_LEVEL_INDEX())
self.__ClickRadioButton(self.cameraModeButtonList, constInfo.GET_CAMERA_MAX_DISTANCE_INDEX())
self.__ClickRadioButton(self.nameColorModeButtonList, constInfo.GET_CHRNAME_COLOR_INDEX())
self.__ClickRadioButton(self.viewTargetBoardButtonList, constInfo.GET_VIEW_OTHER_EMPIRE_PLAYER_TARGET_BOARD())
self.__SetPeacePKMode()
def __ClickRadioButton(self, buttonList, buttonIndex):
try:
selButton=buttonList[buttonIndex]
except IndexError:
return
for eachButton in buttonList:
eachButton.SetUp()
selButton.Down()
def __SetNameColorMode(self, index):
constInfo.SET_CHRNAME_COLOR_INDEX(index)
self.__ClickRadioButton(self.nameColorModeButtonList, index)
def __SetTargetBoardViewMode(self, flag):
constInfo.SET_VIEW_OTHER_EMPIRE_PLAYER_TARGET_BOARD(flag)
self.__ClickRadioButton(self.viewTargetBoardButtonList, flag)
def __SetCameraMode(self, index):
constInfo.SET_CAMERA_MAX_DISTANCE_INDEX(index)
self.__ClickRadioButton(self.cameraModeButtonList, index)
def __SetFogLevel(self, index):
constInfo.SET_FOG_LEVEL_INDEX(index)
self.__ClickRadioButton(self.fogModeButtonList, index)
def __OnClickNameColorModeNormalButton(self):
self.__SetNameColorMode(0)
def __OnClickNameColorModeEmpireButton(self):
self.__SetNameColorMode(1)
def __OnClickTargetBoardViewButton(self):
self.__SetTargetBoardViewMode(0)
def __OnClickTargetBoardNoViewButton(self):
self.__SetTargetBoardViewMode(1)
def __OnClickCameraModeShortButton(self):
self.__SetCameraMode(0)
def __OnClickCameraModeLongButton(self):
self.__SetCameraMode(1)
def __OnClickFogModeLevel0Button(self):
self.__SetFogLevel(0)
def __OnClickFogModeLevel1Button(self):
self.__SetFogLevel(1)
def __OnClickFogModeLevel2Button(self):
self.__SetFogLevel(2)
def __OnClickBlockExchangeButton(self):
self.RefreshBlock()
global blockMode
net.SendChatPacket("/setblockmode " + str(blockMode ^ player.BLOCK_EXCHANGE))
def __OnClickBlockPartyButton(self):
self.RefreshBlock()
global blockMode
net.SendChatPacket("/setblockmode " + str(blockMode ^ player.BLOCK_PARTY))
def __OnClickBlockGuildButton(self):
self.RefreshBlock()
global blockMode
net.SendChatPacket("/setblockmode " + str(blockMode ^ player.BLOCK_GUILD))
def __OnClickBlockWhisperButton(self):
self.RefreshBlock()
global blockMode
net.SendChatPacket("/setblockmode " + str(blockMode ^ player.BLOCK_WHISPER))
def __OnClickBlockFriendButton(self):
self.RefreshBlock()
global blockMode
net.SendChatPacket("/setblockmode " + str(blockMode ^ player.BLOCK_FRIEND))
def __CheckPvPProtectedLevelPlayer(self):
if player.GetStatus(player.LEVEL)<constInfo.PVPMODE_PROTECTED_LEVEL:
self.__SetPeacePKMode()
chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.OPTION_PVPMODE_PROTECT % (constInfo.PVPMODE_PROTECTED_LEVEL))
return 1
return 0
def __SetPKMode(self, mode):
for btn in list(self.pvpModeButtonDict.values()):
btn.SetUp()
if mode in self.pvpModeButtonDict:
self.pvpModeButtonDict[mode].Down()
def __SetPeacePKMode(self):
self.__SetPKMode(player.PK_MODE_PEACE)
def __RefreshPVPButtonList(self):
self.__SetPKMode(player.GetPKMode())
def __OnClickPvPModePeaceButton(self):
if self.__CheckPvPProtectedLevelPlayer():
return
self.__RefreshPVPButtonList()
if constInfo.PVPMODE_ENABLE:
net.SendChatPacket("/pkmode 0", chat.CHAT_TYPE_TALKING)
else:
chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.OPTION_PVPMODE_NOT_SUPPORT)
def __OnClickPvPModeRevengeButton(self):
if self.__CheckPvPProtectedLevelPlayer():
return
self.__RefreshPVPButtonList()
if constInfo.PVPMODE_ENABLE:
net.SendChatPacket("/pkmode 1", chat.CHAT_TYPE_TALKING)
else:
chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.OPTION_PVPMODE_NOT_SUPPORT)
def __OnClickPvPModeFreeButton(self):
if self.__CheckPvPProtectedLevelPlayer():
return
self.__RefreshPVPButtonList()
if constInfo.PVPMODE_ENABLE:
net.SendChatPacket("/pkmode 2", chat.CHAT_TYPE_TALKING)
else:
chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.OPTION_PVPMODE_NOT_SUPPORT)
def __OnClickPvPModeGuildButton(self):
if self.__CheckPvPProtectedLevelPlayer():
return
self.__RefreshPVPButtonList()
if 0 == player.GetGuildID():
chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.OPTION_PVPMODE_CANNOT_SET_GUILD_MODE)
return
if constInfo.PVPMODE_ENABLE:
net.SendChatPacket("/pkmode 4", chat.CHAT_TYPE_TALKING)
else:
chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.OPTION_PVPMODE_NOT_SUPPORT)
def OnChangePKMode(self):
self.__RefreshPVPButtonList()
def OnChangeMusicVolume(self):
pos = self.ctrlMusicVolume.GetSliderPos()
snd.SetMusicVolume(pos)
systemSetting.SetMusicVolume(pos)
def OnChangeSoundVolume(self):
pos = self.ctrlSoundVolume.GetSliderPos()
snd.SetSoundVolume(pos)
systemSetting.SetSoundVolume(pos)
def OnPressEscapeKey(self):
self.Close()
return True
def RefreshBlock(self):
global blockMode
for i in range(len(self.blockButtonList)):
if 0 != (blockMode & (1 << i)):
self.blockButtonList[i].Down()
else:
self.blockButtonList[i].SetUp()
def OnBlockMode(self, mode):
global blockMode
blockMode = mode
self.RefreshBlock()
def Show(self):
self.RefreshBlock()
ui.ScriptWindow.Show(self)
def Close(self):
self.Hide()
if __name__ == "__main__":
import app
import wndMgr
import systemSetting
import mouseModule
import grp
import ui
import chr
import background
import player
#wndMgr.SetOutlineFlag(True)
app.SetMouseHandler(mouseModule.mouseController)
app.SetHairColorEnable(True)
wndMgr.SetMouseHandler(mouseModule.mouseController)
wndMgr.SetScreenSize(systemSetting.GetWidth(), systemSetting.GetHeight())
app.Create("METIN2 CLOSED BETA", systemSetting.GetWidth(), systemSetting.GetHeight(), 1)
mouseModule.mouseController.Create()
wnd = OptionDialog()
wnd.Show()
app.Loop()
-755
View File
@@ -1,755 +0,0 @@
import ui
import grp
import player
import uiToolTip
import net
import localeInfo
import uiScriptLocale
import constInfo
import mouseModule
class PartyMemberInfoBoard(ui.ScriptWindow):
BOARD_WIDTH = 106
BOARD_COLOR = grp.GenerateColor(0.0, 0.0, 0.0, 0.5)
GAUGE_OUT_LINE_COLOR = grp.GenerateColor(1.0, 1.0, 1.0, 0.3)
LINK_COLOR = grp.GenerateColor(0.7607, 0.7607, 0.7607, 1.0)
UNLINK_COLOR = grp.GenerateColor(0.5, 0.5, 0.5, 1.0)
#UNLINK_COLOR = grp.GenerateColor(0.9, 0.4745, 0.4627, 1.0)
PARTY_AFFECT_EXPERIENCE = 0
PARTY_AFFECT_ATTACKER = 1
PARTY_AFFECT_TANKER = 2
PARTY_AFFECT_BUFFER = 3
PARTY_AFFECT_SKILL_MASTER = 4
PARTY_AFFECT_BERSERKER = 5
PARTY_AFFECT_DEFENDER = 6
#PARTY_AFFECT_TIME_BONUS = 5
#PARTY_AFFECT_REGEN_BONUS = 6
PARTY_AFFECT_INCREASE_AREA_150 = 7
PARTY_AFFECT_INCREASE_AREA_200 = 8
AFFECT_STRING_DICT = {}
PARTY_SKILL_HEAL = 1
PARTY_SKILL_WARP = 2
MEMBER_BUTTON_NORMAL = 10
MEMBER_BUTTON_WARP = 11
MEMBER_BUTTON_EXPEL = 12
MEMBER_BUTTON_PATH = "d:/ymir work/ui/game/windows/"
MEMBER_BUTTON_IMAGE_FILE_NAME_DICT = { player.PARTY_STATE_LEADER : "party_state_leader",
player.PARTY_STATE_ATTACKER : "party_state_attacker",
player.PARTY_STATE_BERSERKER : "party_state_berserker",
player.PARTY_STATE_TANKER : "party_state_tanker",
player.PARTY_STATE_DEFENDER : "party_state_defender",
player.PARTY_STATE_BUFFER : "party_state_buffer",
player.PARTY_STATE_SKILL_MASTER : "party_state_skill_master",
MEMBER_BUTTON_NORMAL : "party_state_normal",
MEMBER_BUTTON_WARP : "party_skill_warp",
MEMBER_BUTTON_EXPEL : "party_expel", }
STATE_NAME_DICT = {}
@staticmethod
def _RebuildLocaleStrings():
PartyMemberInfoBoard.AFFECT_STRING_DICT = {
PartyMemberInfoBoard.PARTY_AFFECT_EXPERIENCE : localeInfo.PARTY_BONUS_EXP,
PartyMemberInfoBoard.PARTY_AFFECT_ATTACKER : localeInfo.PARTY_BONUS_ATTACKER,
PartyMemberInfoBoard.PARTY_AFFECT_TANKER : localeInfo.PARTY_BONUS_TANKER,
PartyMemberInfoBoard.PARTY_AFFECT_BUFFER : localeInfo.PARTY_BONUS_BUFFER,
PartyMemberInfoBoard.PARTY_AFFECT_SKILL_MASTER : localeInfo.PARTY_BONUS_SKILL_MASTER,
PartyMemberInfoBoard.PARTY_AFFECT_BERSERKER : localeInfo.PARTY_BONUS_BERSERKER,
PartyMemberInfoBoard.PARTY_AFFECT_DEFENDER : localeInfo.PARTY_BONUS_DEFENDER,
PartyMemberInfoBoard.PARTY_AFFECT_INCREASE_AREA_150 : localeInfo.PARTY_INCREASE_AREA_150,
PartyMemberInfoBoard.PARTY_AFFECT_INCREASE_AREA_200 : localeInfo.PARTY_INCREASE_AREA_200,
}
PartyMemberInfoBoard.STATE_NAME_DICT = {
player.PARTY_STATE_ATTACKER : localeInfo.PARTY_SET_ATTACKER,
player.PARTY_STATE_BERSERKER : localeInfo.PARTY_SET_BERSERKER,
player.PARTY_STATE_TANKER : localeInfo.PARTY_SET_TANKER,
player.PARTY_STATE_DEFENDER : localeInfo.PARTY_SET_DEFENDER,
player.PARTY_STATE_BUFFER : localeInfo.PARTY_SET_BUFFER,
player.PARTY_STATE_SKILL_MASTER : localeInfo.PARTY_SET_SKILL_MASTER,
}
def __init__(self):
ui.ScriptWindow.__init__(self)
self.pid = None
self.vid = None
self.partyAffectImageList = []
self.stateButtonDict = {}
self.affectValueDict = {}
self.state = -1
self.isShowStateButton = False
self.__LoadBoard()
self.__CreateAffectToolTip()
self.__CreateStateButton()
self.Show()
def __del__(self):
ui.ScriptWindow.__del__(self)
print(" =============================== DESTROIED PartyMemberInfoBoard")
def __LoadBoard(self):
try:
pyScrLoader = ui.PythonScriptLoader()
pyScrLoader.LoadScriptFile(self, "UIScript/PartyMemberInfoBoard.py")
except:
import exception
exception.Abort("PartyMemberInfoBoard.__LoadBoard.LoadScript")
try:
self.nameTextLine = self.GetChild("NamePrint")
self.gauge = self.GetChild("Gauge")
self.stateButton = self.GetChild("StateButton")
self.partyAffectImageList.append(self.GetChild("ExperienceImage"))
self.partyAffectImageList.append(self.GetChild("AttackerImage"))
self.partyAffectImageList.append(self.GetChild("DefenderImage"))
self.partyAffectImageList.append(self.GetChild("BufferImage"))
self.partyAffectImageList.append(self.GetChild("SkillMasterImage"))
self.partyAffectImageList.append(self.GetChild("TimeBonusImage"))
self.partyAffectImageList.append(self.GetChild("RegenBonus"))
self.partyAffectImageList.append(self.GetChild("IncreaseArea150"))
self.partyAffectImageList.append(self.GetChild("IncreaseArea200"))
self.stateButton.SetEvent(ui.__mem_func__(self.OnMouseLeftButtonDown))
except:
import exception
exception.Abort("PartyMemberInfoBoard.__LoadBoard.BindObject")
self.__SetAffectsMouseEvent()
self.__HideAllAffects()
def Destroy(self):
self.ClearDictionary()
self.nameTextLine = None
self.gauge = None
self.stateButton = None
for img in self.partyAffectImageList:
img.OnMouseOverIn = None
img.OnMouseOverOut = None
self.partyAffectImageList = []
self.stateButtonDict = {}
self.leaderButton = None
self.attackerButton = None
self.tankerButton = None
self.Hide()
def __SetAffectsMouseEvent(self):
for i in range(len(self.partyAffectImageList)):
self.partyAffectImageList[i].OnMouseOverIn = lambda selfArg = self, index = i: selfArg.OnAffectOverIn(index)
for i in range(len(self.partyAffectImageList)):
self.partyAffectImageList[i].OnMouseOverOut = lambda selfArg = self, index = i: selfArg.OnAffectOverOut(index)
def __HideAllAffects(self):
for img in self.partyAffectImageList:
img.Hide()
def __CreateAffectToolTip(self):
affectToolTip = uiToolTip.ToolTip(220)
affectToolTip.Hide()
self.affectToolTip = affectToolTip
def __CreateStateButton(self):
for key, name in list(self.MEMBER_BUTTON_IMAGE_FILE_NAME_DICT.items()):
if key == player.PARTY_STATE_LEADER:
continue
button = ui.Button()
button.SetUpVisual(self.MEMBER_BUTTON_PATH + name + "_01.sub")
button.SetOverVisual(self.MEMBER_BUTTON_PATH + name + "_02.sub")
button.SetDownVisual(self.MEMBER_BUTTON_PATH + name + "_03.sub")
button.Hide()
self.stateButtonDict[key] = button
for state, name in list(self.STATE_NAME_DICT.items()):
button = self.stateButtonDict[state]
button.SetToolTipText(name)
button.SetEvent(ui.__mem_func__(self.OnSelectState), state)
self.stateButtonDict[self.MEMBER_BUTTON_NORMAL].SetEvent(ui.__mem_func__(self.OnSelectState), -1)
self.stateButtonDict[self.MEMBER_BUTTON_NORMAL].SetToolTipText(localeInfo.PARTY_SET_NORMAL)
self.stateButtonDict[self.MEMBER_BUTTON_WARP].SetEvent(ui.__mem_func__(self.OnWarp))
self.stateButtonDict[self.MEMBER_BUTTON_WARP].SetToolTipText(localeInfo.PARTY_RECALL_MEMBER)
self.stateButtonDict[self.MEMBER_BUTTON_EXPEL].SetToolTipText(localeInfo.TARGET_BUTTON_EXCLUDE)
self.stateButtonDict[self.MEMBER_BUTTON_EXPEL].SetEvent(ui.__mem_func__(self.OnExpel))
def __GetPartySkillLevel(self):
slotIndex = player.GetSkillSlotIndex(player.SKILL_INDEX_TONGSOL)
skillGrade = player.GetSkillGrade(slotIndex)
skillLevel = player.GetSkillLevel(slotIndex)
return skillLevel + skillGrade*20
def __AppendStateButton(self, x, y, state):
if state == self.state:
button = self.stateButtonDict[self.MEMBER_BUTTON_NORMAL]
else:
button = self.stateButtonDict[state]
button.SetPosition(x, y)
button.Show()
def __ShowStateButton(self):
self.isShowStateButton = True
(x, y) = self.GetGlobalPosition()
xPos = x + 110
skillLevel = self.__GetPartySkillLevel()
## Tanker
if skillLevel >= 10:
self.__AppendStateButton(xPos, y, player.PARTY_STATE_ATTACKER)
xPos += 23
## Attacker
if skillLevel >= 20:
self.__AppendStateButton(xPos, y, player.PARTY_STATE_BERSERKER)
xPos += 23
## Tanker
if skillLevel >= 20:
self.__AppendStateButton(xPos, y, player.PARTY_STATE_TANKER)
xPos += 23
## Buffer
if skillLevel >= 25:
self.__AppendStateButton(xPos, y, player.PARTY_STATE_BUFFER)
xPos += 23
## Skill Master
if skillLevel >= 35:
self.__AppendStateButton(xPos, y, player.PARTY_STATE_SKILL_MASTER)
xPos += 23
## Defender
if skillLevel >= 40:
self.__AppendStateButton(xPos, y, player.PARTY_STATE_DEFENDER)
xPos += 23
## Warp
#if skillLevel >= 35:
# if self.stateButtonDict.has_key(self.MEMBER_BUTTON_WARP):
# button = self.stateButtonDict[self.MEMBER_BUTTON_WARP]
# button.SetPosition(xPos, y)
# button.Show()
# xPos += 23
## Expel
if self.MEMBER_BUTTON_EXPEL in self.stateButtonDict:
button = self.stateButtonDict[self.MEMBER_BUTTON_EXPEL]
button.SetPosition(xPos, y)
button.Show()
xPos += 23
def __HideStateButton(self):
self.isShowStateButton = False
for button in list(self.stateButtonDict.values()):
button.Hide()
def __GetAffectNumber(self, img):
for i in range(self.partyAffectImageList):
if img == self.partyAffectImageList[i]:
return i
return -1
def SetCharacterName(self, name):
self.nameTextLine.SetText(name)
def GetCharacterName(self):
return self.nameTextLine.GetText()
def SetCharacterPID(self, pid):
self.pid = pid
def SetCharacterVID(self, vid):
self.vid = vid
def GetCharacterPID(self):
return self.pid
def GetCharacterVID(self):
return self.vid
def SetCharacterHP(self, hpPercentage):
hpPercentage = max(0, hpPercentage)
self.gauge.SetPercentage(hpPercentage, 100)
def SetCharacterState(self, state):
if self.state == state:
return
self.state = state
self.stateButton.Show()
name = self.MEMBER_BUTTON_IMAGE_FILE_NAME_DICT[self.MEMBER_BUTTON_NORMAL]
if state in self.MEMBER_BUTTON_IMAGE_FILE_NAME_DICT:
name = self.MEMBER_BUTTON_IMAGE_FILE_NAME_DICT[state]
self.stateButton.SetUpVisual(self.MEMBER_BUTTON_PATH + name + "_01.sub")
self.stateButton.SetOverVisual(self.MEMBER_BUTTON_PATH + name + "_02.sub")
self.stateButton.SetDownVisual(self.MEMBER_BUTTON_PATH + name + "_03.sub")
def SetAffect(self, affectSlotIndex, affectValue):
if affectSlotIndex >= len(self.partyAffectImageList):
return
if affectValue > 0:
self.partyAffectImageList[affectSlotIndex].Show()
else:
self.partyAffectImageList[affectSlotIndex].Hide()
self.affectValueDict[affectSlotIndex] = affectValue
def Link(self):
self.nameTextLine.SetPackedFontColor(self.LINK_COLOR)
self.gauge.Show()
def Unlink(self):
self.vid = None
self.nameTextLine.SetPackedFontColor(self.UNLINK_COLOR)
self.gauge.Hide()
self.__HideAllAffects()
def OnSelectState(self, state):
self.__HideStateButton()
if state <= 0:
net.SendPartySetStatePacket(self.pid, self.state, False)
else:
if self.state <= 0:
net.SendPartySetStatePacket(self.pid, state, True)
else:
net.SendPartySetStatePacket(self.pid, self.state, False)
net.SendPartySetStatePacket(self.pid, state, True)
def OnWarp(self):
self.__HideStateButton()
if self.vid:
net.SendPartyUseSkillPacket(self.PARTY_SKILL_WARP, self.vid)
def OnExpel(self):
self.__HideStateButton()
if not self.pid:
return
net.SendPartyRemovePacket(self.pid)
def OnMouseLeftButtonDown(self):
if self.vid:
player.SetTarget(self.vid)
player.OpenCharacterMenu(self.vid)
if mouseModule.mouseController.isAttached():
attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
net.SendExchangeStartPacket(self.vid)
net.SendExchangeItemAddPacket(attachedSlotPos, 0)
mouseModule.mouseController.DeattachObject()
return
if player.IsPartyLeader(player.GetMainCharacterIndex()):
if player.PARTY_STATE_LEADER != self.state:
if self.isShowStateButton:
self.__HideStateButton()
else:
self.__ShowStateButton()
def OnMouseLeftButtonUp(self):
if self.vid:
player.SetTarget(self.vid)
player.OpenCharacterMenu(self.vid)
if mouseModule.mouseController.isAttached():
attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
net.SendExchangeStartPacket(self.vid)
net.SendExchangeItemAddPacket(attachedSlotPos, 0)
mouseModule.mouseController.DeattachObject()
def OnMouseRightButtonDown(self):
self.OnMouseLeftButtonDown()
def OnAffectOverIn(self, index):
if index not in self.AFFECT_STRING_DICT:
return
if index not in self.affectValueDict:
return
(x, y) = self.GetGlobalPosition()
self.affectToolTip.ClearToolTip()
self.affectToolTip.SetTitle(self.AFFECT_STRING_DICT[index](self.affectValueDict[index]))
self.affectToolTip.SetToolTipPosition(x + index*12, y + 11)
self.affectToolTip.ShowToolTip()
def OnAffectOverOut(self, index):
self.affectToolTip.HideToolTip()
class PartyMenu(ui.ThinBoard):
# Locale-independent button identifiers (never use translated strings as dict keys)
BTN_HEAL_ALL = 0
BTN_BREAK_UP = 1
BTN_LEAVE = 2
def __init__(self):
ui.ThinBoard.__init__(self)
self.buttonDict = {}
self.distributionMode = 0
self.isLeader = False
self.showingButtonList = []
self.modeButtonList = {}
self.__CreateButtons()
self.__CreateModeButtons()
def __del__(self):
ui.ThinBoard.__del__(self)
def Destroy(self):
self.buttonDict = {}
self.showingButtonList = []
self.modeButtonList = {}
def __CreateModeButtons(self):
self.modeTitle = ui.MakeTextLine(self)
self.modeTitle.SetText(localeInfo.PARTY_EXP_DISTRIBUTION_MODE)
self.modeButtonList = {}
level = ui.RadioButton()
level.SetParent(self)
level.SetWindowHorizontalAlignCenter()
level.SetEvent(ui.__mem_func__(self.OnClickEXPLevel))
level.SetUpVisual("d:/ymir work/ui/public/large_button_01.sub")
level.SetOverVisual("d:/ymir work/ui/public/large_button_02.sub")
level.SetDownVisual("d:/ymir work/ui/public/large_button_03.sub")
level.SetText(localeInfo.PARTY_EXP_DISTRIBUTION_MODE_LEVEL)
level.SetToolTipText(localeInfo.PARTY_EXP_DISTRIBUTION_MODE_LEVEL_TOOLTIP, 70)
level.Show()
self.modeButtonList[player.PARTY_EXP_NON_DISTRIBUTION] = level
parity = ui.RadioButton()
parity.SetParent(self)
parity.SetWindowHorizontalAlignCenter()
parity.SetEvent(ui.__mem_func__(self.OnClickEXPDistributeParity))
parity.SetUpVisual("d:/ymir work/ui/public/large_button_01.sub")
parity.SetOverVisual("d:/ymir work/ui/public/large_button_02.sub")
parity.SetDownVisual("d:/ymir work/ui/public/large_button_03.sub")
parity.SetText(localeInfo.PARTY_EXP_DISTRIBUTION_MODE_PARITY)
parity.SetToolTipText(localeInfo.PARTY_EXP_DISTRIBUTION_MODE_PARITY_TOOLTIP, 70)
parity.Show()
self.modeButtonList[player.PARTY_EXP_DISTRIBUTION_PARITY] = parity
self.ChangePartyParameter(self.distributionMode)
def __CreateButtons(self):
buttonConfig = (
(self.BTN_HEAL_ALL, "PARTY_HEAL_ALL_MEMBER",
"d:/ymir work/ui/game/windows/Party_Skill_Heal",
ui.__mem_func__(self.OnPartyUseSkill)),
(self.BTN_BREAK_UP, "PARTY_BREAK_UP",
"d:/ymir work/ui/game/windows/Party_Disband",
net.SendPartyExitPacket),
(self.BTN_LEAVE, "PARTY_LEAVE",
"d:/ymir work/ui/game/windows/Party_Exit",
net.SendPartyExitPacket),
)
for btnId, localeAttr, imgBase, event in buttonConfig:
button = ui.Button()
button.SetParent(self)
button.SetWindowHorizontalAlignCenter()
button.SetToolTipText(getattr(localeInfo, localeAttr))
button.SetUpVisual(imgBase + "_01.sub")
button.SetOverVisual(imgBase + "_02.sub")
button.SetDownVisual(imgBase + "_03.sub")
button.SetEvent(event)
self.buttonDict[btnId] = button
def __ClearShowingButtons(self):
self.showingButtonList = []
def __ArrangeButtons(self):
STEP_SIZE = 37
showingButtonCount = len(self.showingButtonList)
xPos = (showingButtonCount-1) * (-STEP_SIZE/2)
for button in self.showingButtonList:
button.SetPosition(xPos, 15)
button.Show()
xPos += 37
yPos = 85
for button in list(self.modeButtonList.values()):
button.SetPosition(0, yPos)
yPos += 25
self.UpdateRect()
def __ShowButton(self, name):
if name not in self.buttonDict:
return
self.showingButtonList.append(self.buttonDict[name])
self.__ArrangeButtons()
def __HideButton(self, name):
if name not in self.buttonDict:
return
searchingButton = self.buttonDict[name]
searchingButton.Hide()
for btn in self.showingButtonList:
if btn == searchingButton:
self.showingButtonList.remove(btn)
self.__ArrangeButtons()
def ShowLeaderButton(self):
self.isLeader = True
self.__ClearShowingButtons()
self.__ShowButton(self.BTN_BREAK_UP)
def ShowMemberButton(self):
self.isLeader = False
self.__ClearShowingButtons()
self.__ShowButton(self.BTN_LEAVE)
def OnPartyUseSkill(self):
net.SendPartyUseSkillPacket(PartyMemberInfoBoard.PARTY_SKILL_HEAL, 0)
self.__HideButton(self.BTN_HEAL_ALL)
def PartyHealReady(self):
self.__ShowButton(self.BTN_HEAL_ALL)
def __UpAllModeButtons(self):
for button in list(self.modeButtonList.values()):
button.SetUp()
def __SetModeButton(self, mode):
self.__UpAllModeButtons()
self.modeButtonList[mode].Down()
self.distributionMode = mode
def OnClickEXPLevel(self):
self.__SetModeButton(self.distributionMode)
if self.isLeader:
net.SendPartyParameterPacket(player.PARTY_EXP_NON_DISTRIBUTION)
def OnClickEXPDistributeParity(self):
self.__SetModeButton(self.distributionMode)
if self.isLeader:
net.SendPartyParameterPacket(player.PARTY_EXP_DISTRIBUTION_PARITY)
def ChangePartyParameter(self, distributionMode):
try:
self.__SetModeButton(distributionMode)
except:
pass
class PartyWindow(ui.Window):
def __init__(self):
ui.Window.__init__(self)
self.SetPosition(10, 52)
self.partyMemberInfoBoardList = []
self.__CreatePartyMenuButton()
self.__CreatePartyMenu()
def __del__(self):
ui.Window.__del__(self)
print(" =============================== DESTROIED PartyWindow")
def Destroy(self):
self.DestroyPartyMemberInfoBoard()
self.partyMenu.Destroy()
self.partyMenuButton = None
self.partyMenu = None
def DestroyPartyMemberInfoBoard(self):
for board in self.partyMemberInfoBoardList:
board.Destroy()
self.partyMemberInfoBoardList = []
def __CreatePartyMenuButton(self):
partyMenuButton = ui.Button()
partyMenuButton.SetParent(self)
partyMenuButton.SetWindowHorizontalAlignCenter()
partyMenuButton.SetWindowVerticalAlignBottom()
partyMenuButton.SetPosition(0, 20)
partyMenuButton.SetUpVisual("d:/ymir work/ui/game/windows/Party_Menu_Open_01.sub")
partyMenuButton.SetOverVisual("d:/ymir work/ui/game/windows/Party_Menu_Open_02.sub")
partyMenuButton.SetDownVisual("d:/ymir work/ui/game/windows/Party_Menu_Open_03.sub")
partyMenuButton.SetEvent(ui.__mem_func__(self.OnTogglePartyMenu))
partyMenuButton.Show()
self.partyMenuButton = partyMenuButton
def __CreatePartyMenu(self):
partyMenu = PartyMenu()
partyMenu.SetSize(106, 70 + 70)
partyMenu.Hide()
self.partyMenu = partyMenu
def AddPartyMember(self, pid, name):
board = self.__FindPartyMemberInfoBoardByPID(pid)
if None == board:
board = PartyMemberInfoBoard()
board.SetParent(self)
board.SetCharacterPID(pid)
self.partyMemberInfoBoardList.append(board)
self.__ArrangePartyMemberInfoBoard()
self.UpdateRect()
if not name:
name = localeInfo.PARTY_MEMBER_OFFLINE
board.SetCharacterName(name)
board.Unlink()
self.Show()
def RemovePartyMember(self, pid):
board = self.__FindPartyMemberInfoBoardByPID(pid)
if None == board:
return
vid = board.GetCharacterVID()
if None != vid and player.IsMainCharacterIndex(vid):
self.ExitParty()
player.ExitParty()
else:
board.Destroy()
player.RemovePartyMember(pid)
self.partyMemberInfoBoardList.remove(board)
self.__ArrangePartyMemberInfoBoard()
self.UpdateRect()
def UpdatePartyMemberInfo(self, pid):
board = self.__FindPartyMemberInfoBoardByPID(pid)
if None == board:
return
state = player.GetPartyMemberState(pid)
hpPercentage = player.GetPartyMemberHPPercentage(pid)
affectsList = player.GetPartyMemberAffects(pid)
board.SetCharacterState(state)
board.SetCharacterHP(hpPercentage)
for i in range(len(affectsList)):
board.SetAffect(i, affectsList[i])
vid = board.GetCharacterVID()
if None != vid:
if player.IsMainCharacterIndex(vid):
if player.PARTY_STATE_LEADER == player.GetPartyMemberState(pid):
self.partyMenu.ShowLeaderButton()
else:
self.partyMenu.ShowMemberButton()
def LinkPartyMember(self, pid, vid):
board = self.__FindPartyMemberInfoBoardByPID(pid)
if None == board:
return
board.Link()
board.SetCharacterVID(vid)
def UnlinkPartyMember(self, pid):
board = self.__FindPartyMemberInfoBoardByPID(pid)
if None == board:
return
board.Unlink()
def UnlinkAllPartyMember(self):
for board in self.partyMemberInfoBoardList:
board.Unlink()
def ExitParty(self):
self.partyMenu.Hide()
self.DestroyPartyMemberInfoBoard()
self.Hide()
def __ArrangePartyMemberInfoBoard(self):
count = 0
newHeight = 20
for board in self.partyMemberInfoBoardList:
board.SetPosition(0, count * (board.GetHeight() + 2))
count += 1
newHeight += board.GetHeight() + 2
self.SetSize(PartyMemberInfoBoard.BOARD_WIDTH, newHeight)
(x, y) = self.GetGlobalPosition()
self.partyMenu.SetPosition(10, y + newHeight + 2)
def __FindPartyMemberInfoBoardByVID(self, vid):
for board in self.partyMemberInfoBoardList:
if vid == board.GetCharacterVID():
return board
return None
def __FindPartyMemberInfoBoardByPID(self, pid):
for board in self.partyMemberInfoBoardList:
if pid == board.GetCharacterPID():
return board
return None
def PartyHealReady(self):
self.partyMenu.PartyHealReady()
def ChangePartyParameter(self, distributionMode):
self.partyMenu.ChangePartyParameter(distributionMode)
def OnTogglePartyMenu(self):
if self.partyMenu.IsShow():
self.partyMenuButton.SetUpVisual("d:/ymir work/ui/game/windows/Party_Menu_Open_01.sub")
self.partyMenuButton.SetOverVisual("d:/ymir work/ui/game/windows/Party_Menu_Open_02.sub")
self.partyMenuButton.SetDownVisual("d:/ymir work/ui/game/windows/Party_Menu_Open_03.sub")
self.partyMenu.Hide()
else:
self.partyMenuButton.SetUpVisual("d:/ymir work/ui/game/windows/Party_Menu_Close_01.sub")
self.partyMenuButton.SetOverVisual("d:/ymir work/ui/game/windows/Party_Menu_Close_02.sub")
self.partyMenuButton.SetDownVisual("d:/ymir work/ui/game/windows/Party_Menu_Close_03.sub")
self.partyMenu.Show()
PartyMemberInfoBoard._RebuildLocaleStrings()
localeInfo.RegisterReloadCallback(PartyMemberInfoBoard._RebuildLocaleStrings)
-72
View File
@@ -1,72 +0,0 @@
import grp
import ui
import wndMgr
import app
class PhaseCurtain(ui.Bar):
def __init__(self):
print("NEW CURTAIN ----------------------------------------------------------------------------")
ui.Bar.__init__(self, "CURTAIN")
self.speed = 0.1
self.curAlpha = 0.0
self.event = 0
self.args = -1
self.FadeInFlag = False
self.SetWindowName("PhaseCurtain")
self.AddFlag("float")
def __del__(self):
print("---------------------------------------------------------------------------- DELETE CURTAIN")
ui.Bar.__del__(self)
def SAFE_FadeOut(self, event, args = -1):
self.FadeOut(ui.__mem_func__(event), args)
def FadeOut(self, event, args = -1):
self.curAlpha = 0.0
self.SetAlpha(self.curAlpha)
#self.SetTop()
self.Show()
self.event = event
self.args = args
def FadeIn(self):
self.event = 0
self.FadeInFlag = True
def SetAlpha(self, alpha):
self.SetSize(wndMgr.GetScreenWidth(), wndMgr.GetScreenHeight())
color = grp.GenerateColor(0.0, 0.0, 0.0, alpha)
self.SetColor(color)
def OnUpdate(self):
if 0 != self.event:
self.curAlpha += self.speed
if self.curAlpha >= 1.0:
self.curAlpha = 1.0
# Use only this timer when event fade out was added
event=self.event
self.event = 0
#print "Fade out complete event executed"
if -1 != self.args:
event(self.args)
else:
event()
elif True == self.FadeInFlag:
self.curAlpha -= self.speed
if self.curAlpha <= 0.0:
self.curAlpha = 0.0
self.eventFadeIn = 0
self.FadeInFlag = False
self.Hide()
self.SetAlpha(self.curAlpha)
-104
View File
@@ -1,104 +0,0 @@
import wndMgr
import ui
import ime
import app
class PickMoneyDialog(ui.ScriptWindow):
def __init__(self):
ui.ScriptWindow.__init__(self)
self.unitValue = 1
self.maxValue = 0
self.eventAccept = 0
def __del__(self):
ui.ScriptWindow.__del__(self)
def LoadDialog(self):
try:
pyScrLoader = ui.PythonScriptLoader()
pyScrLoader.LoadScriptFile(self, "UIScript/PickMoneyDialog.py")
except:
import exception
exception.Abort("MoneyDialog.LoadDialog.LoadScript")
try:
self.board = self.GetChild("board")
self.maxValueTextLine = self.GetChild("max_value")
self.pickValueEditLine = self.GetChild("money_value")
self.acceptButton = self.GetChild("accept_button")
self.cancelButton = self.GetChild("cancel_button")
except:
import exception
exception.Abort("MoneyDialog.LoadDialog.BindObject")
self.pickValueEditLine.SetReturnEvent(ui.__mem_func__(self.OnAccept))
self.pickValueEditLine.SetEscapeEvent(ui.__mem_func__(self.Close))
self.acceptButton.SetEvent(ui.__mem_func__(self.OnAccept))
self.cancelButton.SetEvent(ui.__mem_func__(self.Close))
self.board.SetCloseEvent(ui.__mem_func__(self.Close))
def Destroy(self):
self.ClearDictionary()
self.eventAccept = 0
self.maxValue = 0
self.pickValueEditLine = 0
self.acceptButton = 0
self.cancelButton = 0
self.board = None
def SetTitleName(self, text):
self.board.SetTitleName(text)
def SetAcceptEvent(self, event):
self.eventAccept = event
def SetMax(self, max):
self.pickValueEditLine.SetMax(max)
def Open(self, maxValue, unitValue = 1):
width = self.GetWidth()
(mouseX, mouseY) = wndMgr.GetMousePosition()
if mouseX + width/2 > wndMgr.GetScreenWidth():
xPos = wndMgr.GetScreenWidth() - width
elif mouseX - width/2 < 0:
xPos = 0
else:
xPos = mouseX - width/2
self.SetPosition(xPos, mouseY - self.GetHeight() - 20)
if app.IsRTL():
self.maxValueTextLine.SetText("/" + str(maxValue))
else:
self.maxValueTextLine.SetText(" / " + str(maxValue))
self.pickValueEditLine.SetText(str(unitValue))
self.pickValueEditLine.SetFocus()
ime.SetCursorPosition(1)
self.unitValue = unitValue
self.maxValue = maxValue
self.Show()
self.SetTop()
def Close(self):
self.pickValueEditLine.KillFocus()
self.Hide()
def OnAccept(self):
text = self.pickValueEditLine.GetText()
if len(text) > 0 and text.isdigit():
money = int(text)
money = min(money, self.maxValue)
if money > 0:
if self.eventAccept:
self.eventAccept(money)
self.Close()
-59
View File
@@ -1,59 +0,0 @@
import ui
import player
import chr
import textTail
class PlayerGauge(ui.Gauge):
def __init__(self, parent):
ui.Gauge.__init__(self)
self.SetParent(parent)
self.AddFlag("not_pick")
self.MakeGauge(100, "red")
self.curHP = 0
self.maxHP = 0
self.showAlways = False
def __del__(self):
ui.Gauge.__del__(self)
def Hide(self):
self.SetPosition(-100, -100)
ui.Gauge.Hide(self)
def OnUpdate(self):
playerIndex = player.GetMainCharacterIndex()
(x, y, z)=textTail.GetPosition(playerIndex)
isChat = textTail.IsChat(playerIndex)
ui.Gauge.SetPosition(self, int(x - self.GetWidth() // 2), int(y + 5) + isChat * 17)
def RefreshGauge(self):
self.curHP = player.GetStatus(player.HP)
self.maxHP = player.GetStatus(player.MAX_HP)
self.SetPercentage(self.curHP, self.maxHP)
if self.showAlways:
self.Show()
else:
if self.IsShow():
if self.curHP > self.maxHP // 2:
self.Hide()
else:
if self.curHP < self.maxHP // 2:
self.OnUpdate()
self.Show()
def EnableShowAlways(self):
self.showAlways = True
self.RefreshGauge()
def DisableShowAlways(self):
self.showAlways = False
self.RefreshGauge()
-74
View File
@@ -1,74 +0,0 @@
import net
import ui
import networkModule
###################################################################################################
## PointReset
class PointResetDialog(ui.ScriptWindow):
def __init__(self):
ui.ScriptWindow.__init__(self)
self.ConfirmDialog = ui.ScriptWindow()
def LoadDialog(self):
try:
PythonScriptLoader = ui.PythonScriptLoader()
PythonScriptLoader.LoadScriptFile(self, "uiscript/questiondialog2.py")
PythonScriptLoader.LoadScriptFile(self.ConfirmDialog, "uiscript/questiondialog2.py")
except:
import exception
exception.Abort("PointResetDialog.LoadDialog.LoadObject")
try:
GetObject = self.ConfirmDialog.GetChild
self.ConfirmText = GetObject("message1")
self.ConfirmText2 = GetObject("message2")
self.ConfirmAcceptButton = GetObject("accept")
self.ConfirmCancelButton = GetObject("cancel")
except:
import exception
exception.Abort("PointResetDialog.LoadWindow.BindObject")
self.GetChild("message1").SetText("스탯/스킬 포인트를 초기화해주겠네.")
self.GetChild("message2").SetText("가격은 500원이야. 어때, 초기화할텐가?")
self.GetChild("accept").SetEvent(ui.__mem_func__(self.OpenConfirmDialog))
self.GetChild("cancel").SetEvent(ui.__mem_func__(self.Close))
## Confirm Dialog
self.ConfirmText.SetText("현재 레벨의 경험치가 모두 없어진다네.")
self.ConfirmText.SetFontColor(1.0, 0.3, 0.3)
self.ConfirmText2.SetText("정말 초기화하고 싶은가?")
self.ConfirmAcceptButton.SetEvent(ui.__mem_func__(self.ResetPoint))
self.ConfirmCancelButton.SetEvent(ui.__mem_func__(self.Close))
def Destroy(self):
self.ClearDictionary()
self.ConfirmDialog.ClearDictionary()
self.ConfirmAcceptButton.SetEvent(0)
self.ConfirmCancelButton.SetEvent(0)
self.ConfirmDialog = 0
self.ConfirmText = 0
self.ConfirmAcceptButton = 0
self.ConfirmCancelButton = 0
def OpenDialog(self):
self.Show()
def OpenConfirmDialog(self):
self.ConfirmDialog.Show()
self.ConfirmDialog.SetTop()
def ResetPoint(self):
net.SendChatPacket("/pointreset")
self.Close()
def Close(self):
self.ConfirmDialog.Hide()
self.Hide()
return True
def OnPressEscapeKey(self):
self.Close()
return True
-347
View File
@@ -1,347 +0,0 @@
import ui
import snd
import shop
import mouseModule
import player
import chr
import net
import uiCommon
import localeInfo
import chat
import item
import systemSetting
import player
g_isBuildingPrivateShop = False
g_itemPriceDict={}
g_privateShopAdvertisementBoardDict={}
def Clear():
global g_itemPriceDict
global g_isBuildingPrivateShop
g_itemPriceDict={}
g_isBuildingPrivateShop = False
def IsPrivateShopItemPriceList():
global g_itemPriceDict
if g_itemPriceDict:
return True
else:
return False
def IsBuildingPrivateShop():
global g_isBuildingPrivateShop
if player.IsOpenPrivateShop() or g_isBuildingPrivateShop:
return True
else:
return False
def SetPrivateShopItemPrice(itemVNum, itemPrice):
global g_itemPriceDict
g_itemPriceDict[int(itemVNum)]=itemPrice
def GetPrivateShopItemPrice(itemVNum):
try:
global g_itemPriceDict
return g_itemPriceDict[itemVNum]
except KeyError:
return 0
def UpdateADBoard():
for key in list(g_privateShopAdvertisementBoardDict.keys()):
g_privateShopAdvertisementBoardDict[key].Show()
def DeleteADBoard(vid):
if vid not in g_privateShopAdvertisementBoardDict:
return
del g_privateShopAdvertisementBoardDict[vid]
class PrivateShopAdvertisementBoard(ui.ThinBoard):
def __init__(self):
ui.ThinBoard.__init__(self, "UI_BOTTOM")
self.vid = None
self.__MakeTextLine()
def __del__(self):
ui.ThinBoard.__del__(self)
def __MakeTextLine(self):
self.textLine = ui.TextLine()
self.textLine.SetParent(self)
self.textLine.SetWindowHorizontalAlignCenter()
self.textLine.SetWindowVerticalAlignCenter()
self.textLine.SetHorizontalAlignCenter()
self.textLine.SetVerticalAlignCenter()
self.textLine.Show()
def Open(self, vid, text):
self.vid = vid
self.textLine.SetText(text)
self.textLine.UpdateRect()
self.SetSize(len(text)*6 + 10*2, 20)
self.Show()
g_privateShopAdvertisementBoardDict[vid] = self
def OnMouseLeftButtonUp(self):
if not self.vid:
return
net.SendOnClickPacket(self.vid)
return True
def OnUpdate(self):
if not self.vid:
return
if systemSetting.IsShowSalesText():
self.Show()
x, y = chr.GetProjectPosition(self.vid, 220)
self.SetPosition(x - self.GetWidth()/2, y - self.GetHeight()/2)
else:
for key in list(g_privateShopAdvertisementBoardDict.keys()):
if player.GetMainCharacterIndex() == key: # When the private shop is visible and closed, the player's own shop ID changes.
g_privateShopAdvertisementBoardDict[key].Show()
x, y = chr.GetProjectPosition(player.GetMainCharacterIndex(), 220)
g_privateShopAdvertisementBoardDict[key].SetPosition(x - self.GetWidth()/2, y - self.GetHeight()/2)
else:
g_privateShopAdvertisementBoardDict[key].Hide()
class PrivateShopBuilder(ui.ScriptWindow):
def __init__(self):
#print "NEW MAKE_PRIVATE_SHOP_WINDOW ----------------------------------------------------------------"
ui.ScriptWindow.__init__(self)
self.__LoadWindow()
self.itemStock = {}
self.tooltipItem = None
self.priceInputBoard = None
self.title = ""
def __del__(self):
#print "------------------------------------------------------------- DELETE MAKE_PRIVATE_SHOP_WINDOW"
ui.ScriptWindow.__del__(self)
def __LoadWindow(self):
try:
pyScrLoader = ui.PythonScriptLoader()
pyScrLoader.LoadScriptFile(self, "UIScript/PrivateShopBuilder.py")
except:
import exception
exception.Abort("PrivateShopBuilderWindow.LoadWindow.LoadObject")
try:
GetObject = self.GetChild
self.nameLine = GetObject("NameLine")
self.itemSlot = GetObject("ItemSlot")
self.btnOk = GetObject("OkButton")
self.btnClose = GetObject("CloseButton")
self.titleBar = GetObject("TitleBar")
except:
import exception
exception.Abort("PrivateShopBuilderWindow.LoadWindow.BindObject")
self.btnOk.SetEvent(ui.__mem_func__(self.OnOk))
self.btnClose.SetEvent(ui.__mem_func__(self.OnClose))
self.titleBar.SetCloseEvent(ui.__mem_func__(self.OnClose))
self.itemSlot.SetSelectEmptySlotEvent(ui.__mem_func__(self.OnSelectEmptySlot))
self.itemSlot.SetSelectItemSlotEvent(ui.__mem_func__(self.OnSelectItemSlot))
self.itemSlot.SetOverInItemEvent(ui.__mem_func__(self.OnOverInItem))
self.itemSlot.SetOverOutItemEvent(ui.__mem_func__(self.OnOverOutItem))
def Destroy(self):
self.ClearDictionary()
self.nameLine = None
self.itemSlot = None
self.btnOk = None
self.btnClose = None
self.titleBar = None
self.priceInputBoard = None
def Open(self, title):
self.title = title
if len(title) > 25:
title = title[:22] + "..."
self.itemStock = {}
shop.ClearPrivateShopStock()
self.nameLine.SetText(title)
self.SetCenterPosition()
self.Refresh()
self.Show()
global g_isBuildingPrivateShop
g_isBuildingPrivateShop = True
def Close(self):
global g_isBuildingPrivateShop
g_isBuildingPrivateShop = False
self.title = ""
self.itemStock = {}
shop.ClearPrivateShopStock()
self.Hide()
def SetItemToolTip(self, tooltipItem):
self.tooltipItem = tooltipItem
def Refresh(self):
getitemVNum=player.GetItemIndex
getItemCount=player.GetItemCount
setitemVNum=self.itemSlot.SetItemSlot
delItem=self.itemSlot.ClearSlot
for i in range(shop.SHOP_SLOT_COUNT):
if i not in self.itemStock:
delItem(i)
continue
pos = self.itemStock[i]
itemCount = getItemCount(*pos)
if itemCount <= 1:
itemCount = 0
setitemVNum(i, getitemVNum(*pos), itemCount)
self.itemSlot.RefreshSlot()
def OnSelectEmptySlot(self, selectedSlotPos):
isAttached = mouseModule.mouseController.isAttached()
if isAttached:
attachedSlotType = mouseModule.mouseController.GetAttachedType()
attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
mouseModule.mouseController.DeattachObject()
if player.SLOT_TYPE_INVENTORY != attachedSlotType and player.SLOT_TYPE_DRAGON_SOUL_INVENTORY != attachedSlotType:
return
attachedInvenType = player.SlotTypeToInvenType(attachedSlotType)
itemVNum = player.GetItemIndex(attachedInvenType, attachedSlotPos)
item.SelectItem(itemVNum)
if item.IsAntiFlag(item.ANTIFLAG_GIVE) or item.IsAntiFlag(item.ANTIFLAG_MYSHOP):
chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.PRIVATE_SHOP_CANNOT_SELL_ITEM)
return
priceInputBoard = uiCommon.MoneyInputDialog()
priceInputBoard.SetTitle(localeInfo.PRIVATE_SHOP_INPUT_PRICE_DIALOG_TITLE)
priceInputBoard.SetAcceptEvent(ui.__mem_func__(self.AcceptInputPrice))
priceInputBoard.SetCancelEvent(ui.__mem_func__(self.CancelInputPrice))
priceInputBoard.Open()
itemPrice=GetPrivateShopItemPrice(itemVNum)
if itemPrice>0:
priceInputBoard.SetValue(itemPrice)
self.priceInputBoard = priceInputBoard
self.priceInputBoard.itemVNum = itemVNum
self.priceInputBoard.sourceWindowType = attachedInvenType
self.priceInputBoard.sourceSlotPos = attachedSlotPos
self.priceInputBoard.targetSlotPos = selectedSlotPos
def OnSelectItemSlot(self, selectedSlotPos):
isAttached = mouseModule.mouseController.isAttached()
if isAttached:
snd.PlaySound("sound/ui/loginfail.wav")
mouseModule.mouseController.DeattachObject()
else:
if not selectedSlotPos in self.itemStock:
return
invenType, invenPos = self.itemStock[selectedSlotPos]
shop.DelPrivateShopItemStock(invenType, invenPos)
snd.PlaySound("sound/ui/drop.wav")
del self.itemStock[selectedSlotPos]
self.Refresh()
def AcceptInputPrice(self):
if not self.priceInputBoard:
return True
text = self.priceInputBoard.GetText()
if not text:
return True
if not text.isdigit():
return True
if int(text) <= 0:
return True
attachedInvenType = self.priceInputBoard.sourceWindowType
sourceSlotPos = self.priceInputBoard.sourceSlotPos
targetSlotPos = self.priceInputBoard.targetSlotPos
for privatePos, (itemWindowType, itemSlotIndex) in list(self.itemStock.items()):
if itemWindowType == attachedInvenType and itemSlotIndex == sourceSlotPos:
shop.DelPrivateShopItemStock(itemWindowType, itemSlotIndex)
del self.itemStock[privatePos]
price = int(self.priceInputBoard.GetText())
if IsPrivateShopItemPriceList():
SetPrivateShopItemPrice(self.priceInputBoard.itemVNum, price)
shop.AddPrivateShopItemStock(attachedInvenType, sourceSlotPos, targetSlotPos, price)
self.itemStock[targetSlotPos] = (attachedInvenType, sourceSlotPos)
snd.PlaySound("sound/ui/drop.wav")
self.Refresh()
#####
self.priceInputBoard = None
return True
def CancelInputPrice(self):
self.priceInputBoard = None
return True
def OnOk(self):
if not self.title:
return
if 0 == len(self.itemStock):
return
shop.BuildPrivateShop(self.title)
self.Close()
def OnClose(self):
self.Close()
def OnPressEscapeKey(self):
self.Close()
return True
def OnOverInItem(self, slotIndex):
if self.tooltipItem:
if slotIndex in self.itemStock:
self.tooltipItem.SetPrivateShopBuilderItem(*self.itemStock[slotIndex] + (slotIndex,))
def OnOverOutItem(self):
if self.tooltipItem:
self.tooltipItem.HideToolTip()
-926
View File
@@ -1,926 +0,0 @@
import ui
import dbg
import app
import grp
import grpImage
import event
import time
import wndMgr
import net
import sys
QUEST_BOARD_IMAGE_DIR = 'd:/ymir work/ui/game/questboard/'
cur_questpage_number = 1
entire_questbutton_number = 0
entire_questpage_number = 1
# TOOLTIP_IMAGE_BOX
class ToolTipImageBox(ui.ImageBox):
def __init__(self):
ui.ImageBox.__init__(self)
self.DestroyToolTip()
def __del__(self):
ui.ImageBox.__del__(self)
def CreateToolTip(self, parent, title, desc, x, y):
import uiToolTip
self.toolTip = uiToolTip.ToolTip()
self.toolTip.SetWindowHorizontalAlignCenter()
self.toolTip.SetFollow(False)
self.toolTip.SetTitle(title)
self.toolTip.SetPosition(x, y)
desc = desc.replace("|", "/")
for line in desc.split("/"):
self.toolTip.AutoAppendTextLine(line)
self.toolTip.ResizeToolTip()
self.toolTip.Hide()
def DestroyToolTip(self):
self.toolTip = None
def OnMouseOverIn(self):
if self.toolTip:
self.toolTip.SetTop()
self.toolTip.Show()
def OnMouseOverOut(self):
if self.toolTip:
self.toolTip.Hide()
# END_OF_TOOLTIP_IMAGE_BOX
class QuestCurtain(ui.Window):
CURTAIN_TIME = 0.25
CURTAIN_SPEED = 200
BarHeight = 60
OnDoneEventList = []
def __init__(self,layer="TOP_MOST"):
ui.Window.__init__(self,layer)
self.TopBar = ui.Bar("TOP_MOST")
self.BottomBar = ui.Bar("TOP_MOST")
self.TopBar.Show()
self.BottomBar.Show()
self.TopBar.SetColor(0xff000000)
self.BottomBar.SetColor(0xff000000)
self.TopBar.SetPosition(0,-self.BarHeight)
self.TopBar.SetSize(wndMgr.GetScreenWidth(),self.BarHeight)
self.BottomBar.SetPosition(0,wndMgr.GetScreenHeight())
self.BottomBar.SetSize(wndMgr.GetScreenWidth(),self.BarHeight)
self.CurtainMode = 0
self.lastclock = time.perf_counter()
def Close(self):
self.CurtainMode = 0
self.TopBar.SetPosition(0, -self.BarHeight-1)
self.BottomBar.SetPosition(0, wndMgr.GetScreenHeight()+1)
for OnDoneEvent in QuestCurtain.OnDoneEventList:
OnDoneEvent(*(self,))
QuestCurtain.OnDoneEventList = []
def OnUpdate(self):
dt = time.perf_counter() - self.lastclock
if self.CurtainMode>0:
self.TopBar.SetPosition(0, int(self.TopBar.GetGlobalPosition()[1]+dt*self.CURTAIN_SPEED))
self.BottomBar.SetPosition(0, int(self.BottomBar.GetGlobalPosition()[1]-dt*self.CURTAIN_SPEED))
if self.TopBar.GetGlobalPosition()[1]>0:
self.TopBar.SetPosition(0,0)
self.BottomBar.SetPosition(0,wndMgr.GetScreenHeight()-self.BarHeight)
self.CurtainMode = 0
elif self.CurtainMode<0:
self.TopBar.SetPosition(0, int(self.TopBar.GetGlobalPosition()[1]-dt*self.CURTAIN_SPEED))
self.BottomBar.SetPosition(0, int(self.BottomBar.GetGlobalPosition()[1]+dt*self.CURTAIN_SPEED))
if self.TopBar.GetGlobalPosition()[1]<-self.BarHeight:
self.TopBar.SetPosition(0,-self.BarHeight-1)
self.BottomBar.SetPosition(0,wndMgr.GetScreenHeight()+1)
self.Close()
self.lastclock = time.perf_counter()
class EventCurtain(ui.Bar):
COLOR_WHITE = 0.0
COLOR_BLACK = 1.0
DEFAULT_FADE_SPEED = 0.035
STATE_WAIT = 0
STATE_OUT = 1
STATE_IN = 2
def __init__(self, index):
print("NEW EVENT CURTAIN ----------------------------------------------------------------------------")
ui.Bar.__init__(self, "CURTAIN")
self.SetWindowName("EventCurtain")
self.AddFlag("float")
self.SetSize(wndMgr.GetScreenWidth(), wndMgr.GetScreenHeight())
self.Hide()
self.fadeColor = 1.0
self.curAlpha = 0.0
self.FadeInFlag = False
self.state = self.STATE_WAIT
self.speed = 1.0
self.eventIndex = index
def __del__(self):
print("---------------------------------------------------------------------------- DELETE EVENT CURTAIN")
ui.Bar.__del__(self)
def SetAlpha(self, alpha):
color = grp.GenerateColor(self.fadeColor, self.fadeColor, self.fadeColor, alpha)
self.SetColor(color)
def FadeOut(self, speed):
self.curAlpha = 0.0
self.__StartFade(self.STATE_OUT, 0.0, speed)
def FadeIn(self, speed):
self.curAlpha = 1.0
self.__StartFade(self.STATE_IN, 0.0, speed)
def WhiteOut(self, speed):
self.curAlpha = 0.0
self.__StartFade(self.STATE_OUT, 1.0, speed)
def WhiteIn(self, speed):
self.curAlpha = 1.0
self.__StartFade(self.STATE_IN, 1.0, speed)
def __StartFade(self, state, color, speed):
self.state = state
self.fadeColor = color
self.Show()
self.speed = self.DEFAULT_FADE_SPEED
if 0 != speed:
self.speed = speed
def __EndFade(self):
event.EndEventProcess(self.eventIndex)
def OnUpdate(self):
if self.STATE_OUT == self.state:
self.curAlpha += self.speed
if self.curAlpha >= 1.0:
self.state = self.STATE_WAIT
self.curAlpha = 1.0
self.__EndFade()
elif self.STATE_IN == self.state:
self.curAlpha -= self.speed
if self.curAlpha <= 0.0:
self.state = self.STATE_WAIT
self.curAlpha = 0.0
self.__EndFade()
self.Hide()
self.SetAlpha(self.curAlpha)
class BarButton(ui.Button):
ColorUp = 0x40999999
ColorDown = 0x40aaaacc
ColorOver = 0x40ddddff
UP=0
DOWN=1
OVER=2
def __init__(self, layer = "UI",
aColorUp = ColorUp,
aColorDown = ColorDown,
aColorOver = ColorOver):
ui.Button.__init__(self,layer)
self.state = self.UP
self.colortable = aColorUp, aColorDown, aColorOver
def OnRender(self):
x,y = self.GetGlobalPosition()
grp.SetColor(self.colortable[self.state])
grp.RenderBar(x,y,self.GetWidth(),self.GetHeight())
def CallEvent(self):
self.state = self.UP
ui.Button.CallEvent(self)
def DownEvent(self):
self.state = self.DOWN
def ShowToolTip(self):
self.state = self.OVER
def HideToolTip(self):
self.state = self.UP
class DescriptionWindow(ui.Window):
def __init__(self,idx):
ui.Window.__init__(self, "TOP_MOST")
self.descIndex = idx
def __del__(self):
ui.Window.__del__(self)
def OnRender(self):
event.RenderEventSet(self.descIndex)
class QuestDialog(ui.ScriptWindow):
TITLE_STATE_NONE = 0
TITLE_STATE_APPEAR = 1
TITLE_STATE_SHOW = 2
TITLE_STATE_DISAPPEAR = 3
SKIN_NONE = 0
SKIN_CINEMA = 5
QUEST_BUTTON_MAX_NUM = 8
def __init__(self,skin,idx):
ui.ScriptWindow.__init__(self)
self.SetWindowName("quest dialog")
self.focusIndex = 0
self.board = None
self.sx = 0
self.sy = 0
self.skin = skin
if skin == 3:
event.SetRestrictedCount(idx,36)
else:
event.SetRestrictedCount(idx,60)
QuestCurtain.BarHeight = (wndMgr.GetScreenHeight()-wndMgr.GetScreenWidth() * 9 // 16) // 2
if QuestCurtain.BarHeight<0:
QuestCurtain.BarHeight = 50
if not ('QuestCurtain' in QuestDialog.__dict__):
QuestDialog.QuestCurtain = QuestCurtain()
QuestDialog.QuestCurtain.Show()
QuestDialog.QuestCurtain.CurtainMode = 1
self.nextCurtainMode = 0
if self.skin:
QuestDialog.QuestCurtain.CurtainMode = 1
self.nextCurtainMode = 0
self.LoadDialog(self.skin)
else:
QuestDialog.QuestCurtain.CurtainMode = -1
self.nextCurtainMode = -1
self.descIndex = idx
self.descWindow = DescriptionWindow(idx)
self.descWindow.Show()
self.eventCurtain = EventCurtain(idx)
event.SetEventHandler(idx, self)
self.OnCloseEvent = None
self.btnAnswer = None
self.btnNext = None
self.imgLeft = None
self.imgTop = None
self.imgBackground = None
self.imgTitle = None
self.titleState = self.TITLE_STATE_NONE
self.titleShowTime = 0
self.images = []
self.prevbutton = None
self.nextbutton = None
# QUEST_INPUT
self.needInputString = False
self.editSlot = None
self.editLine = None
# END_OF_QUEST_INPUT
# QUEST_CANCEL - Track if dialog was cancelled
self.bCancelled = False
# END_OF_QUEST_CANCEL
def __del__(self):
ui.ScriptWindow.__del__(self)
def LoadDialog(self, skin):
try:
PythonScriptLoader = ui.PythonScriptLoader()
PythonScriptLoader.LoadScriptFile(self, "uiscript/questdialog.py")
except RuntimeError:
dbg.TraceError("QuestDialog.LoadDialog")
try:
self.board = self.GetChild('board')
except RuntimeError:
dbg.TraceError("QuestDialog.BindObject")
self.SetCenterPosition()
if self.SKIN_CINEMA == skin:
self.board.Hide()
# QUEST_CANCEL
def OnCancel(self):
self.bCancelled = True
self.nextCurtainMode = -1
self.CloseSelf()
# END_OF_QUEST_CANCEL
def CloseSelf(self):
if self.bCancelled:
net.SendQuestCancelPacket()
self.bCancelled = False
QuestDialog.QuestCurtain.CurtainMode = self.nextCurtainMode
self.btnNext = None
self.descWindow = None
self.btnAnswer = None
self.Destroy()
if self.descIndex:
event.ClearEventSet(self.descIndex)
self.descIndex = None
self.focusIndex = 0
def Destroy(self):
self.ClearDictionary()
if self.OnCloseEvent:
self.OnCloseEvent()
self.OnCloseEvent = None
# QUEST_INPUT
if self.needInputString:
if self.editLine:
text = self.editLine.GetText()
net.SendQuestInputStringPacket(text)
# END_OF_QUEST_INPUT
self.imgTitle = None
self.images = None
self.eventCurtain = None
self.board = None
def OnUpdate(self):
if self.skin == self.SKIN_CINEMA:
event.UpdateEventSet(self.descIndex, 50, -(wndMgr.GetScreenHeight() - 44))
# AUTO_RESIZE_BOARD
elif self.skin == 3:
if self.board:
event.UpdateEventSet(self.descIndex, self.board.GetGlobalPosition()[0]+20+self.sx, -self.board.GetGlobalPosition()[1]-20-self.sy)
event.SetEventSetWidth(self.descIndex, self.board.GetWidth()-40)
elif self.skin:
if self.board:
event.UpdateEventSet(self.descIndex, self.board.GetGlobalPosition()[0]+20, -self.board.GetGlobalPosition()[1]-20)
event.SetEventSetWidth(self.descIndex, self.board.GetWidth()-40)
# END_OF_AUTO_RESIZE_BOARD
else:
event.UpdateEventSet(self.descIndex, 0, 0)
if self.TITLE_STATE_NONE != self.titleState:
curTime = app.GetTime()
elapsedTime = app.GetTime() - self.titleShowTime
if self.TITLE_STATE_APPEAR == self.titleState:
self.imgTitle.SetAlpha(elapsedTime*2)
if elapsedTime > 0.5:
self.titleState = self.TITLE_STATE_SHOW
self.titleShowTime = curTime
elif self.TITLE_STATE_SHOW == self.titleState:
if elapsedTime > 1.0:
self.titleState = self.TITLE_STATE_DISAPPEAR
self.titleShowTime = curTime
elif self.TITLE_STATE_DISAPPEAR == self.titleState:
self.imgTitle.SetAlpha(1.0 - elapsedTime*2)
if elapsedTime > 0.5:
self.titleState = self.TITLE_STATE_NONE
self.titleShowTime = curTime
## Set Variables
def AddOnCloseEvent(self, f):
if self.OnCloseEvent:
old = self.OnCloseEvent
def combined(*args, **kwargs):
err = None
try:
old(*args, **kwargs)
except Exception as e:
err = e
f(*args, **kwargs)
if err:
raise err
self.OnCloseEvent = combined
else:
self.OnCloseEvent = f
def AddOnDoneEvent(self,f):
QuestCurtain.OnDoneEventList.append(f)
def SetOnCloseEvent(self,f):
self.OnCloseEvent = f
def SetEventSetPosition(self, x, y):
self.sx = x
self.sy = y
def AdjustEventSetPosition(self, x, y):
self.sx += x
self.sy += y
## Event
# QUEST_CANCEL
def MakeNextButton(self, button_type):
if self.SKIN_NONE == self.skin:
return
yPos = event.GetEventSetLocalYPosition(self.descIndex)
b = BarButton()
b.SetParent(self.board)
b.SetSize(100,26)
b.SetPosition(self.sx+self.board.GetWidth()//2-50,self.sy+yPos)
self.nextButtonType = button_type;
import localeInfo
if event.BUTTON_TYPE_CANCEL == button_type:
b.SetEvent(lambda s=self:(setattr(s, 'bCancelled', True) or None) or event.SelectAnswer(s.descIndex, 254) or s.OnCancel())
b.SetText(localeInfo.UI_CANCEL)
elif event.BUTTON_TYPE_DONE == button_type:
b.SetEvent(lambda s=self:s.CloseSelf())
b.SetText(localeInfo.UI_OK)
elif event.BUTTON_TYPE_NEXT == button_type:
b.SetEvent(lambda s=self:event.SelectAnswer(s.descIndex, 254) or s.CloseSelf())
b.SetText(localeInfo.UI_NEXT)
b.Show()
b.SetTextColor(0xffffffff)
self.btnNext = b
# END_OF_QUEST_CANCEL
def MakeQuestion(self, n): # n is the total number of quest buttons including the final "Close" button
global entire_questbutton_number
global entire_questpage_number
global cur_questpage_number
entire_questpage_number = ((n-2)//7)+1
entire_questbutton_number = n
if not self.board:
return
self.btnAnswer = [self.MakeEachButton(i) for i in range (n)]
import localeInfo
self.prevbutton = self.MakeNextPrevPageButton()
self.prevbutton.SetPosition(self.sx+self.board.GetWidth()//2-164, self.board.GetHeight()//2-16)
self.prevbutton.SetText(localeInfo.UI_PREVPAGE)
self.prevbutton.SetEvent(self.PrevQuestPageEvent, 1, n)
self.nextbutton = self.MakeNextPrevPageButton()
self.nextbutton.SetPosition(self.sx+self.board.GetWidth()//2+112, self.board.GetHeight()//2-16)
self.nextbutton.SetText(localeInfo.UI_NEXTPAGE)
self.nextbutton.SetEvent(self.NextQuestPageEvent, 1, n)
if cur_questpage_number != 1:
cur_questpage_number = 1
def MakeEachButton(self, i):
if self.skin == 3:
button = BarButton("TOP_MOST",0x50000000, 0x50404040, 0x50606060)
button.SetParent(self.board)
button.SetSize(106,26)
button.SetPosition(self.sx + self.board.GetWidth()//2+((i*2)-1)*56-56, self.sy+(event.GetLineCount(self.descIndex))*16+20+5)
button.SetText("a")
button.SetTextColor(0xff000000)
else:
i = i % 8
button = BarButton("TOP_MOST")
button.SetParent(self.board)
button.SetSize(200,26)
button.SetPosition(self.sx + self.board.GetWidth()//2-100,self.sy+(event.GetLineCount(self.descIndex)+i*2)*16+20+5)
button.SetText("a")
button.SetTextColor(0xffffffff)
return button
def MakeNextPrevPageButton(self):
button = BarButton("TOP_MOST")
button.SetParent(self.board)
button.SetSize(52,26)
button.SetText("a")
button.SetTextColor(0xffffffff)
return button
def RefreshQuestPage(self, n):
global cur_questpage_number
global entire_questpage_number
num = 0
Showing_button_inx = (cur_questpage_number-1)* self.QUEST_BUTTON_MAX_NUM
while num < n:
if num >= Showing_button_inx and num < Showing_button_inx + self.QUEST_BUTTON_MAX_NUM:
self.btnAnswer[num].Show()
else:
self.btnAnswer[num].Hide()
num = num + 1
if cur_questpage_number == 1:
self.prevbutton.Hide()
self.nextbutton.Show()
elif cur_questpage_number == entire_questpage_number:
self.prevbutton.Show()
self.nextbutton.Hide()
else:
self.prevbutton.Show()
self.nextbutton.Show()
def NextQuestPageEvent(self, one, n):
global cur_questpage_number
cur_questpage_number = cur_questpage_number + one
self.RefreshQuestPage(n)
def PrevQuestPageEvent(self, one, n):
global cur_questpage_number
cur_questpage_number = cur_questpage_number - one
self.RefreshQuestPage(n)
def ClickAnswerEvent(self, ai):
event.SelectAnswer(self.descIndex, ai)
self.nextbutton = None
self.prevbutton = None
self.CloseSelf()
def AppendQuestion(self, name, idx): # idx starts from 0. See PythonEventManager.cpp line 881
if not self.btnAnswer:
return
self.btnAnswer[idx].SetText(name)
x, y= self.btnAnswer[idx].GetGlobalPosition()
self.btnAnswer[idx].SetEvent(self.ClickAnswerEvent, idx)
global entire_questbutton_number
Showing_button_idx = (cur_questpage_number-1)* self.QUEST_BUTTON_MAX_NUM
if Showing_button_idx <= idx and idx < Showing_button_idx + self.QUEST_BUTTON_MAX_NUM:
self.btnAnswer[idx].Show()
else:
self.btnAnswer[idx].Hide()
if entire_questbutton_number >= self.QUEST_BUTTON_MAX_NUM:
self.nextbutton.Show()
def FadeOut(self, speed):
self.eventCurtain.FadeOut(speed)
def FadeIn(self, speed):
self.eventCurtain.FadeIn(speed)
def WhiteOut(self, speed):
self.eventCurtain.WhiteOut(speed)
def WhiteIn(self, speed):
self.eventCurtain.WhiteIn(speed)
def DoneEvent(self):
self.nextCurtainMode = -1
if self.SKIN_NONE == self.skin or self.SKIN_CINEMA == self.skin:
self.CloseSelf()
def __GetQuestImageFileName(self, filename):
if len(filename) > 1:
if filename[1]!=':':
filename = QUEST_BOARD_IMAGE_DIR+filename
return filename
# QUEST_INPUT
def OnKeyDown(self, key):
if self.btnAnswer == None:
## Handle cases with only unidirectional buttons like 'Next' or 'OK' without choice options
if None != self.btnNext:
if app.DIK_RETURN == key:
self.OnPressEscapeKey()
if app.DIK_UP == key or app.DIK_DOWN == key:
self.btnNext.ShowToolTip()
return True
focusIndex = self.focusIndex;
lastFocusIndex = focusIndex;
#print "QuestDialog key down - focus, last : ", focusIndex, lastFocusIndex
answerCount = len(self.btnAnswer)
if app.DIK_DOWN == key:
focusIndex += 1
if app.DIK_UP == key:
focusIndex -= 1
if focusIndex < 0:
focusIndex = answerCount - 1
if focusIndex >= answerCount:
focusIndex = 0
self.focusIndex = focusIndex;
focusBtn = self.btnAnswer[focusIndex]
lastFocusBtn = self.btnAnswer[lastFocusIndex]
if focusIndex != lastFocusIndex:
focusBtn.ShowToolTip()
lastFocusBtn.HideToolTip()
if app.DIK_RETURN == key:
focusBtn.CallEvent()
return True
def OnPressEscapeKey(self):
# When ESC key is pressed, have the same effect as clicking the "Next" button.
if None != self.btnNext:
## ESC button when all quest text has been displayed
if event.BUTTON_TYPE_CANCEL == self.nextButtonType:
self.bCancelled = True
event.SelectAnswer(self.descIndex, 254)
self.CloseSelf()
## When no action is being performed
elif event.BUTTON_TYPE_DONE == self.nextButtonType:
self.CloseSelf()
## When trying to press Enter or move to next screen
elif event.BUTTON_TYPE_NEXT == self.nextButtonType:
event.SelectAnswer(self.descIndex, 254)
self.CloseSelf()
else:
## When dialog is closed midway or ESC button appears
event.SelectAnswer(self.descIndex, entire_questbutton_number -1 )
self.nextbutton = None
self.prevbutton = None
self.OnCancel()
return True
def OnIMEReturn(self):
if self.needInputString:
self.CloseSelf()
return True
def OnIMEUpdate(self):
if not self.needInputString:
return
if not self.editLine:
return
self.editLine.OnIMEUpdate()
def OnInput(self):
self.needInputString = True
event.AddEventSetLocalYPosition(self.descIndex, 5+10)
yPos = event.GetEventSetLocalYPosition(self.descIndex)
self.editSlot = ui.SlotBar()
self.editSlot.SetSize(200, 18)
self.editSlot.SetPosition(0, yPos)
self.editSlot.SetParent(self.board)
self.editSlot.SetWindowHorizontalAlignCenter()
self.editSlot.Show()
self.editLine = ui.EditLine()
self.editLine.SetParent(self.editSlot)
self.editLine.SetPosition(3, 3)
self.editLine.SetSize(200, 17)
self.editLine.SetMax(30)
self.editLine.SetFocus()
self.editLine.Show()
event.AddEventSetLocalYPosition(self.descIndex, 25+10)
self.MakeNextButton(event.BUTTON_TYPE_DONE)
self.editLine.UpdateRect()
self.editSlot.UpdateRect()
self.board.UpdateRect()
# END_OF_QUEST_INPUT
def OnImage(self, x, y, filename, desc=""):
filename = self.__GetQuestImageFileName(filename)
# IMAGE_EXCEPTION_BUG_FIX
try:
img = ui.MakeImageBox(self.board, filename, x, y)
self.images.append(img)
except RuntimeError:
pass
# END_OF_IMAGE_EXCEPTION_BUG_FIX
# QUEST_IMAGE
def OnInsertItemIcon(self, type, idx, title, desc, index=0, total=1):
if "item" != type:
return
import item
item.SelectItem(idx)
filename = item.GetIconImageFileName()
underTitle = title
if not title and not desc:
title = item.GetItemName()
desc = item.GetItemDescription()
tempDesc = desc
desc = ""
import grpText
lineCount = grpText.GetSplitingTextLineCount(tempDesc, 25)
for i in range(lineCount):
desc += grpText.GetSplitingTextLine(tempDesc, 25, i) + "/"
desc = desc[:-1]
self.OnInsertImage(filename, underTitle, title, desc, index, total)
def OnInsertImage(self, filename, underTitle, title, desc, index=0, total=1):
if index == 0:
event.AddEventSetLocalYPosition(self.descIndex, 24)
y = event.GetEventSetLocalYPosition(self.descIndex)
xBoard, yBoard = self.board.GetGlobalPosition()
try:
img = ToolTipImageBox()
img.SetParent(self.board)
img.LoadImage(filename)
pos_x = (self.board.GetWidth() * (index + 1) // (total + 1)) - (img.GetWidth() // 2)
img.SetPosition(pos_x, y)
#img.SetWindowHorizontalAlignCenter()
img.DestroyToolTip()
if title and desc:
img.CreateToolTip(self.board, title, desc, 0, yBoard + y + img.GetHeight())
img.Show()
self.images.append(img)
except RuntimeError:
pass
event.AddEventSetLocalYPosition(self.descIndex, img.GetHeight() - 20)
if underTitle:
event.AddEventSetLocalYPosition(self.descIndex, 3)
event.InsertTextInline(self.descIndex, underTitle, (self.board.GetWidth() * (index + 1) // (total + 1)))
if index != total - 1:
event.AddEventSetLocalYPosition(self.descIndex, -( 3 + 16 ))
else:
if index == total - 1:
event.AddEventSetLocalYPosition(self.descIndex, 4)
if index != total - 1:
event.AddEventSetLocalYPosition(self.descIndex, -(img.GetHeight() - 20))
# END_OF_QUEST_IMAGE
def OnSize(self, width, height):
self.board.SetSize(width, height)
def OnTitleImage(self, filename):
img = ui.ImageBox("TOP_MOST")
try:
img.SetWindowHorizontalAlignCenter()
img.LoadImage(filename)
img.SetPosition(0, wndMgr.GetScreenHeight() - (75//2) - (32//2))
img.SetAlpha(0.0)
img.Show()
except RuntimeError:
dbg.TraceError("QuestDialog.OnTitleImage(%s)" % filename)
img.Hide()
self.imgTitle = img
self.titleState = self.TITLE_STATE_APPEAR
self.titleShowTime = app.GetTime()
def OnLeftImage(self, imgfile):
imgfile = self.__GetQuestImageFileName(imgfile)
if not self.imgLeft:
self.imgLeft = ui.ExpandedImageBox("TOP_MOST")
self.imgLeft.SetParent(self)
self.imgLeft.SetPosition(0,0)
bd = self.board
bx, by = bd.GetLocalPosition()
bd.SetPosition(160,by)
if self.imgTop:
tx, ty = self.imgTop.GetLocalPosition()
self.imgTop.SetPosition(160,ty)
try:
self.imgLeft.LoadImage(imgfile)
self.imgLeft.SetSize(400,450)
self.imgLeft.SetOrigin(self.imgLeft.GetWidth()//2,self.imgLeft.GetHeight()//2)
self.imgLeft.Show()
except RuntimeError:
import dbg
dbg.TraceError("QuestDialog.OnLeftImage(%s)" % imgfile)
self.imgLeft.Hide()
def OnTopImage(self, imgfile):
imgfile = self.__GetQuestImageFileName(imgfile)
bd = self.board
bx, by = bd.GetLocalPosition()
if not self.imgTop:
self.imgTop = ui.ExpandedImageBox("TOP_MOST")
self.imgTop.SetParent(self)
bd.SetPosition(bx,190)
self.imgTop.SetPosition(bx,10)
try:
self.imgTop.LoadImage(imgfile)
h = self.imgTop.GetHeight()
if h>170:
# need adjust board size
bd.SetPosition(bx,20+h)
bd.SetSize(350,420-h)
self.imgTop.SetSize(350,h)
else:
self.imgTop.SetSize(350,170)
bd.SetPosition(bx,190)
bd.SetSize(350,250)
self.imgTop.SetOrigin(self.imgTop.GetWidth()//2,self.imgTop.GetHeight()//2)
self.imgTop.Show()
except RuntimeError:
dbg.TraceError("QuestDialog.OnTopImage(%s)" % imgfile)
self.imgTop.Hide()
def OnBackgroundImage(self, imgfile):
imgfile = self.__GetQuestImageFileName(imgfile)
c = self.board
w = c.GetWidth()
h = c.GetHeight()
px, py = c.GetLocalPosition()
moved = 0
if not self.imgBackground:
self.imgBackground = ui.ExpandedImageBox("TOP_MOST")
self.imgBackground.SetParent(c)
self.imgBackground.SetPosition(0,0)
self.imgBackground.LoadImage(imgfile)
iw = self.imgBackground.GetWidth()
ih = self.imgBackground.GetHeight()
if self.skin==3:
iw = 256
ih = 333
self.imgBackground.SetSize(iw,ih)
if w < iw:
px -= (iw-w)//2
c.SetPosition(px,py)
w = iw
if h < ih:
py -= (ih-h)//2
c.SetPosition(px,py)
h = ih
if self.skin == 3:
w=256
h = 333
self.sx = 0
self.sy = 100
c.SetSize(w,h)
c.HideInternal()
c.SetWindowHorizontalAlignCenter()
c.SetWindowVerticalAlignCenter()
c.SetPosition(0,0)
if self.skin==3:
c.SetPosition(-190,0)
self.imgBackground.SetWindowHorizontalAlignCenter()
self.imgBackground.SetWindowVerticalAlignCenter()
self.imgBackground.SetPosition(0,0)
self.imgBackground.Show()
-449
View File
@@ -1,449 +0,0 @@
import app
import net
import player
import item
import ui
import uiToolTip
import mouseModule
import localeInfo
import uiCommon
import constInfo
class RefineDialog(ui.ScriptWindow):
makeSocketSuccessPercentage = ( 100, 33, 20, 15, 10, 5, 0 )
upgradeStoneSuccessPercentage = ( 30, 29, 28, 27, 26, 25, 24, 23, 22 )
upgradeArmorSuccessPercentage = ( 99, 66, 33, 33, 33, 33, 33, 33, 33 )
upgradeAccessorySuccessPercentage = ( 99, 88, 77, 66, 33, 33, 33, 33, 33 )
upgradeSuccessPercentage = ( 99, 66, 33, 33, 33, 33, 33, 33, 33 )
def __init__(self):
ui.ScriptWindow.__init__(self)
self.__LoadScript()
self.scrollItemPos = 0
self.targetItemPos = 0
def __LoadScript(self):
self.__LoadQuestionDialog()
try:
pyScrLoader = ui.PythonScriptLoader()
pyScrLoader.LoadScriptFile(self, "uiscript/refinedialog.py")
except:
import exception
exception.Abort("RefineDialog.__LoadScript.LoadObject")
try:
self.board = self.GetChild("Board")
self.titleBar = self.GetChild("TitleBar")
self.successPercentage = self.GetChild("SuccessPercentage")
self.GetChild("AcceptButton").SetEvent(self.OpenQuestionDialog)
self.GetChild("CancelButton").SetEvent(self.Close)
except:
import exception
exception.Abort("RefineDialog.__LoadScript.BindObject")
self.successPercentage.Hide()
toolTip = uiToolTip.ItemToolTip()
toolTip.SetParent(self)
toolTip.SetPosition(15, 38)
toolTip.SetFollow(False)
toolTip.Show()
self.toolTip = toolTip
self.titleBar.SetCloseEvent(ui.__mem_func__(self.Close))
def __del__(self):
ui.ScriptWindow.__del__(self)
def __LoadQuestionDialog(self):
self.dlgQuestion = ui.ScriptWindow()
try:
pyScrLoader = ui.PythonScriptLoader()
pyScrLoader.LoadScriptFile(self.dlgQuestion, "uiscript/questiondialog2.py")
except:
import exception
exception.Abort("RefineDialog.__LoadQuestionDialog.LoadScript")
try:
GetObject=self.dlgQuestion.GetChild
GetObject("message1").SetText(localeInfo.REFINE_DESTROY_WARNING)
GetObject("message2").SetText(localeInfo.REFINE_WARNING2)
GetObject("accept").SetEvent(ui.__mem_func__(self.Accept))
GetObject("cancel").SetEvent(ui.__mem_func__(self.dlgQuestion.Hide))
except:
import exception
exception.Abort("SelectCharacterWindow.__LoadQuestionDialog.BindObject")
def Destroy(self):
self.ClearDictionary()
self.board = 0
self.successPercentage = 0
self.titleBar = 0
self.toolTip = 0
self.dlgQuestion = 0
def GetRefineSuccessPercentage(self, scrollSlotIndex, itemSlotIndex):
if -1 != scrollSlotIndex:
if player.IsRefineGradeScroll(scrollSlotIndex):
curGrade = player.GetItemGrade(itemSlotIndex)
itemIndex = player.GetItemIndex(itemSlotIndex)
item.SelectItem(itemIndex)
itemType = item.GetItemType()
itemSubType = item.GetItemSubType()
if item.ITEM_TYPE_METIN == itemType:
if curGrade >= len(self.upgradeStoneSuccessPercentage):
return 0
return self.upgradeStoneSuccessPercentage[curGrade]
elif item.ITEM_TYPE_ARMOR == itemType:
if item.ARMOR_BODY == itemSubType:
if curGrade >= len(self.upgradeArmorSuccessPercentage):
return 0
return self.upgradeArmorSuccessPercentage[curGrade]
else:
if curGrade >= len(self.upgradeAccessorySuccessPercentage):
return 0
return self.upgradeAccessorySuccessPercentage[curGrade]
else:
if curGrade >= len(self.upgradeSuccessPercentage):
return 0
return self.upgradeSuccessPercentage[curGrade]
for i in range(player.METIN_SOCKET_MAX_NUM+1):
if 0 == player.GetItemMetinSocket(itemSlotIndex, i):
break
return self.makeSocketSuccessPercentage[i]
def Open(self, scrollItemPos, targetItemPos):
self.scrollItemPos = scrollItemPos
self.targetItemPos = targetItemPos
percentage = self.GetRefineSuccessPercentage(scrollItemPos, targetItemPos)
if 0 == percentage:
return
self.successPercentage.SetText(localeInfo.REFINE_SUCCESS_PROBALITY % (percentage))
itemIndex = player.GetItemIndex(targetItemPos)
self.toolTip.ClearToolTip()
metinSlot = []
for i in range(player.METIN_SOCKET_MAX_NUM):
metinSlot.append(player.GetItemMetinSocket(targetItemPos, i))
self.toolTip.AddItemData(itemIndex, metinSlot)
self.UpdateDialog()
self.SetTop()
self.Show()
def UpdateDialog(self):
newWidth = self.toolTip.GetWidth() + 30
# MR-15: Adjust button padding for refine window
newHeight = self.toolTip.GetHeight() + 108
# MR-15: -- END OF -- Adjust button padding for refine window
self.board.SetSize(newWidth, newHeight)
# MR-15: Adjust button padding for refine window
self.titleBar.SetWidth(newWidth - 15)
# MR-15: -- END OF -- Adjust button padding for refine window
self.SetSize(newWidth, newHeight)
(x, y) = self.GetLocalPosition()
self.SetPosition(x, y)
def OpenQuestionDialog(self):
percentage = self.GetRefineSuccessPercentage(-1, self.targetItemPos)
if 100 == percentage:
self.Accept()
return
self.dlgQuestion.SetTop()
self.dlgQuestion.Show()
def Accept(self):
net.SendItemUseToItemPacket(self.scrollItemPos, self.targetItemPos)
self.Close()
def Close(self):
self.dlgQuestion.Hide()
self.Hide()
def OnPressEscapeKey(self):
self.Close()
return True
class RefineDialogNew(ui.ScriptWindow):
def __init__(self):
ui.ScriptWindow.__init__(self)
self.__Initialize()
self.isLoaded = False
def __Initialize(self):
self.dlgQuestion = None
self.children = []
self.vnum = 0
self.targetItemPos = 0
self.dialogHeight = 0
self.cost = 0
self.percentage = 0
self.type = 0
def __LoadScript(self):
try:
pyScrLoader = ui.PythonScriptLoader()
pyScrLoader.LoadScriptFile(self, "uiscript/refinedialog.py")
except:
import exception
exception.Abort("RefineDialog.__LoadScript.LoadObject")
try:
self.board = self.GetChild("Board")
self.titleBar = self.GetChild("TitleBar")
self.probText = self.GetChild("SuccessPercentage")
self.costText = self.GetChild("Cost")
self.successPercentage = self.GetChild("SuccessPercentage")
self.GetChild("AcceptButton").SetEvent(self.OpenQuestionDialog)
self.GetChild("CancelButton").SetEvent(self.CancelRefine)
except:
import exception
exception.Abort("RefineDialog.__LoadScript.BindObject")
self.successPercentage.Hide()
toolTip = uiToolTip.ItemToolTip()
toolTip.SetParent(self)
toolTip.SetFollow(False)
toolTip.SetPosition(15, 38)
toolTip.Show()
self.toolTip = toolTip
self.slotList = []
for i in range(3):
slot = self.__MakeSlot()
slot.SetParent(toolTip)
slot.SetWindowVerticalAlignCenter()
self.slotList.append(slot)
itemImage = self.__MakeItemImage()
itemImage.SetParent(toolTip)
itemImage.SetWindowVerticalAlignCenter()
itemImage.SetPosition(-35, 0)
self.itemImage = itemImage
self.titleBar.SetCloseEvent(ui.__mem_func__(self.CancelRefine))
self.isLoaded = True
def __del__(self):
ui.ScriptWindow.__del__(self)
def __MakeSlot(self):
slot = ui.ImageBox()
slot.LoadImage("d:/ymir work/ui/public/slot_base.sub")
slot.Show()
self.children.append(slot)
return slot
def __MakeItemImage(self):
itemImage = ui.ImageBox()
itemImage.Show()
self.children.append(itemImage)
return itemImage
def __MakeThinBoard(self):
thinBoard = ui.ThinBoard()
thinBoard.SetParent(self)
thinBoard.Show()
self.children.append(thinBoard)
return thinBoard
def Destroy(self):
self.ClearDictionary()
self.dlgQuestion = None
self.board = 0
self.probText = 0
self.costText = 0
self.titleBar = 0
self.toolTip = 0
self.successPercentage = None
self.slotList = []
self.children = []
def Open(self, targetItemPos, nextGradeItemVnum, cost, prob, type):
if False == self.isLoaded:
self.__LoadScript()
self.__Initialize()
self.targetItemPos = targetItemPos
self.vnum = nextGradeItemVnum
self.cost = cost
self.percentage = prob
self.type = type
self.probText.SetText(localeInfo.REFINE_SUCCESS_PROBALITY % (self.percentage))
self.costText.SetText(localeInfo.REFINE_COST % (self.cost))
self.toolTip.ClearToolTip()
metinSlot = []
for i in range(player.METIN_SOCKET_MAX_NUM):
metinSlot.append(player.GetItemMetinSocket(targetItemPos, i))
attrSlot = []
for i in range(player.ATTRIBUTE_SLOT_MAX_NUM):
attrSlot.append(player.GetItemAttribute(targetItemPos, i))
self.toolTip.AddRefineItemData(nextGradeItemVnum, metinSlot, attrSlot)
item.SelectItem(nextGradeItemVnum)
self.itemImage.LoadImage(item.GetIconImageFileName())
xSlotCount, ySlotCount = item.GetItemSize()
for slot in self.slotList:
slot.Hide()
for i in range(min(3, ySlotCount)):
self.slotList[i].SetPosition(-35, i * 32 - (ySlotCount - 1) * 16)
self.slotList[i].Show()
self.dialogHeight = self.toolTip.GetHeight() + 46
self.UpdateDialog()
self.SetTop()
self.Show()
def Close(self):
# MR-15: Multiline dialog messages
if self.dlgQuestion:
self.dlgQuestion.Hide()
# MR-15: -- END OF -- Multiline dialog messages
self.dlgQuestion = None
self.Hide()
def AppendMaterial(self, vnum, count):
slot = self.__MakeSlot()
slot.SetParent(self)
slot.SetPosition(15, self.dialogHeight)
itemImage = self.__MakeItemImage()
itemImage.SetParent(slot)
item.SelectItem(vnum)
itemImage.LoadImage(item.GetIconImageFileName())
thinBoard = self.__MakeThinBoard()
thinBoard.SetPosition(50, self.dialogHeight)
thinBoard.SetSize(self.toolTip.GetWidth(), 20)
textLine = ui.TextLine()
textLine.SetParent(thinBoard)
textLine.SetFontName(localeInfo.UI_DEF_FONT)
textLine.SetPackedFontColor(0xffdddddd)
textLine.SetText("%s x %02d" % (item.GetItemName(), count))
textLine.SetOutline()
textLine.SetFeather(False)
textLine.SetWindowVerticalAlignCenter()
textLine.SetVerticalAlignCenter()
if app.IsRTL():
(x,y) = textLine.GetTextSize()
textLine.SetPosition(x, 0)
else:
textLine.SetPosition(15, 0)
textLine.Show()
self.children.append(textLine)
self.dialogHeight += 34
self.UpdateDialog()
def UpdateDialog(self):
newWidth = self.toolTip.GetWidth() + 60
# MR-15: Adjust button padding for refine window
newHeight = self.dialogHeight + 79
# MR-15: -- END OF -- Adjust button padding for refine window
newHeight -= 8
if app.IsRTL():
self.board.SetPosition(newWidth, 0)
(x, y) = self.titleBar.GetLocalPosition()
self.titleBar.SetPosition(newWidth - 15, y)
self.board.SetSize(newWidth, newHeight)
self.toolTip.SetPosition(15 + 35, 38)
self.titleBar.SetWidth(newWidth - 15)
self.SetSize(newWidth, newHeight)
(x, y) = self.GetLocalPosition()
self.SetPosition(x, y)
def OpenQuestionDialog(self):
if 100 == self.percentage:
self.Accept()
return
if 5 == self.type: ## ������ �ູ��
self.Accept()
return
dlgQuestion = uiCommon.QuestionDialog2()
dlgQuestion.SetText2(localeInfo.REFINE_WARNING2)
dlgQuestion.SetAcceptEvent(ui.__mem_func__(self.Accept))
dlgQuestion.SetCancelEvent(ui.__mem_func__(dlgQuestion.Close))
if 3 == self.type: ## ��ö
dlgQuestion.SetText1(localeInfo.REFINE_DESTROY_WARNING_WITH_BONUS_PERCENT_1)
# MR-15: Update refining messages
dlgQuestion.SetText2(localeInfo.REFINE_POPUP_NO_DOWNGRADE_MESSAGE)
# MR-15: -- END OF -- Update refining messages
elif 2 == self.type: ## �ູ��
dlgQuestion.SetText1(localeInfo.REFINE_DOWN_GRADE_WARNING)
else:
dlgQuestion.SetText1(localeInfo.REFINE_DESTROY_WARNING)
dlgQuestion.Open()
self.dlgQuestion = dlgQuestion
def Accept(self):
net.SendRefinePacket(self.targetItemPos, self.type)
self.Close()
def CancelRefine(self):
net.SendRefinePacket(255, 255)
self.Close()
def OnPressEscapeKey(self):
self.CancelRefine()
return True
-65
View File
@@ -1,65 +0,0 @@
import dbg
import app
import net
import ui
###################################################################################################
## Restart
class RestartDialog(ui.ScriptWindow):
def __init__(self):
ui.ScriptWindow.__init__(self)
def __del__(self):
ui.ScriptWindow.__del__(self)
def LoadDialog(self):
try:
pyScrLoader = ui.PythonScriptLoader()
pyScrLoader.LoadScriptFile(self, "uiscript/restartdialog.py")
except Exception as msg:
import sys
(type, msg, tb)=sys.exc_info()
dbg.TraceError("RestartDialog.LoadDialog - %s:%s" % (type, msg))
app.Abort()
return 0
try:
self.restartHereButton=self.GetChild("restart_here_button")
self.restartTownButton=self.GetChild("restart_town_button")
except:
import sys
(type, msg, tb)=sys.exc_info()
dbg.TraceError("RestartDialog.LoadDialog - %s:%s" % (type, msg))
app.Abort()
return 0
self.restartHereButton.SetEvent(ui.__mem_func__(self.RestartHere))
self.restartTownButton.SetEvent(ui.__mem_func__(self.RestartTown))
return 1
def Destroy(self):
self.restartHereButton=0
self.restartTownButton=0
self.ClearDictionary()
def OpenDialog(self):
self.Show()
def Close(self):
self.Hide()
return True
def RestartHere(self):
net.SendChatPacket("/restart_here")
def RestartTown(self):
net.SendChatPacket("/restart_town")
def OnPressExitKey(self):
return True
def OnPressEscapeKey(self):
return True
-710
View File
@@ -1,710 +0,0 @@
import ui
import mouseModule
import player
import net
import snd
import safebox
import chat
import app
import localeInfo
import uiScriptLocale
class PasswordDialog(ui.ScriptWindow):
def __init__(self):
ui.ScriptWindow.__init__(self)
self.__LoadDialog()
self.sendMessage = "/safebox_password "
def __del__(self):
ui.ScriptWindow.__del__(self)
def __LoadDialog(self):
try:
pyScrLoader = ui.PythonScriptLoader()
pyScrLoader.LoadScriptFile(self, "uiscript/passworddialog.py")
except:
import exception
exception.Abort("PasswordDialog.__LoadDialog.LoadObject")
try:
self.passwordValue = self.GetChild("password_value")
self.acceptButton = self.GetChild("accept_button")
self.cancelButton = self.GetChild("cancel_button")
self.titleName = self.GetChild("TitleName")
self.GetChild("titlebar").SetCloseEvent(ui.__mem_func__(self.CloseDialog))
except:
import exception
exception.Abort("PasswordDialog.__LoadDialog.BindObject")
self.passwordValue.OnIMEReturn = self.OnAccept
self.passwordValue.OnPressEscapeKey = self.OnCancel
self.acceptButton.SetEvent(ui.__mem_func__(self.OnAccept))
self.cancelButton.SetEvent(ui.__mem_func__(self.OnCancel))
# MR-17: Set secret mode for password input
self.passwordValue.SetSecretMode(1)
# MR-17: -- END OF -- Set secret mode for password input
def Destroy(self):
self.ClearDictionary()
self.passwordValue = None
self.acceptButton = None
self.cancelButton = None
self.titleName = None
def SetTitle(self, title):
self.titleName.SetText(title)
def SetSendMessage(self, msg):
self.sendMessage = msg
def ShowDialog(self):
self.passwordValue.SetText("")
self.passwordValue.SetFocus()
self.SetCenterPosition()
self.Show()
def CloseDialog(self):
self.passwordValue.KillFocus()
self.Hide()
def OnAccept(self):
net.SendChatPacket(self.sendMessage + self.passwordValue.GetText())
self.CloseDialog()
return True
def OnCancel(self):
self.CloseDialog()
return True
class ChangePasswordDialog(ui.ScriptWindow):
def __init__(self):
ui.ScriptWindow.__init__(self)
self.__LoadDialog()
def __del__(self):
ui.ScriptWindow.__del__(self)
def __LoadDialog(self):
self.dlgMessage = ui.ScriptWindow()
try:
pyScrLoader = ui.PythonScriptLoader()
pyScrLoader.LoadScriptFile(self.dlgMessage, "uiscript/popupdialog.py")
self.dlgMessage.GetChild("message").SetText(localeInfo.SAFEBOX_WRONG_PASSWORD)
self.dlgMessage.GetChild("accept").SetEvent(ui.__mem_func__(self.OnCloseMessageDialog))
except:
import exception
exception.Abort("SafeboxWindow.__LoadDialog.LoadObject")
def LoadDialog(self):
try:
pyScrLoader = ui.PythonScriptLoader()
pyScrLoader.LoadScriptFile(self, "uiscript/changepassworddialog.py")
except:
import exception
exception.Abort("ChangePasswordDialog.LoadDialog.LoadObject")
try:
self.GetChild("accept_button").SetEvent(ui.__mem_func__(self.OnAccept))
self.GetChild("cancel_button").SetEvent(ui.__mem_func__(self.OnCancel))
self.GetChild("titlebar").SetCloseEvent(ui.__mem_func__(self.OnCancel))
oldPassword = self.GetChild("old_password_value")
newPassword = self.GetChild("new_password_value")
newPasswordCheck = self.GetChild("new_password_check_value")
except:
import exception
exception.Abort("ChangePasswordDialog.LoadDialog.BindObject")
oldPassword.SetTabEvent(lambda arg=1: self.OnNextFocus(arg))
newPassword.SetTabEvent(lambda arg=2: self.OnNextFocus(arg))
newPasswordCheck.SetTabEvent(lambda arg=3: self.OnNextFocus(arg))
oldPassword.SetReturnEvent(lambda arg=1: self.OnNextFocus(arg))
newPassword.SetReturnEvent(lambda arg=2: self.OnNextFocus(arg))
newPasswordCheck.SetReturnEvent(ui.__mem_func__(self.OnAccept))
oldPassword.OnPressEscapeKey = self.OnCancel
newPassword.OnPressEscapeKey = self.OnCancel
newPasswordCheck.OnPressEscapeKey = self.OnCancel
# MR-17: Set secret mode for password input
oldPassword.SetSecretMode(1)
newPassword.SetSecretMode(1)
newPasswordCheck.SetSecretMode(1)
# MR-17: -- END OF -- Set secret mode for password input
self.oldPassword = oldPassword
self.newPassword = newPassword
self.newPasswordCheck = newPasswordCheck
def OnNextFocus(self, arg):
if 1 == arg:
self.oldPassword.KillFocus()
self.newPassword.SetFocus()
elif 2 == arg:
self.newPassword.KillFocus()
self.newPasswordCheck.SetFocus()
elif 3 == arg:
self.newPasswordCheck.KillFocus()
self.oldPassword.SetFocus()
def Destroy(self):
self.ClearDictionary()
self.dlgMessage.ClearDictionary()
self.oldPassword = None
self.newPassword = None
self.newPasswordCheck = None
def Open(self):
self.oldPassword.SetText("")
self.newPassword.SetText("")
self.newPasswordCheck.SetText("")
self.oldPassword.SetFocus()
self.SetCenterPosition()
self.SetTop()
self.Show()
def Close(self):
self.oldPassword.SetText("")
self.newPassword.SetText("")
self.newPasswordCheck.SetText("")
self.oldPassword.KillFocus()
self.newPassword.KillFocus()
self.newPasswordCheck.KillFocus()
self.Hide()
def OnAccept(self):
oldPasswordText = self.oldPassword.GetText()
newPasswordText = self.newPassword.GetText()
newPasswordCheckText = self.newPasswordCheck.GetText()
if newPasswordText != newPasswordCheckText:
self.dlgMessage.SetCenterPosition()
self.dlgMessage.SetTop()
self.dlgMessage.Show()
return True
net.SendChatPacket("/safebox_change_password %s %s" % (oldPasswordText, newPasswordText))
self.Close()
return True
def OnCancel(self):
self.Close()
return True
def OnCloseMessageDialog(self):
self.newPassword.SetText("")
self.newPasswordCheck.SetText("")
self.newPassword.SetFocus()
self.dlgMessage.Hide()
class SafeboxWindow(ui.ScriptWindow):
BOX_WIDTH = 176
def __init__(self):
ui.ScriptWindow.__init__(self)
self.tooltipItem = None
self.sellingSlotNumber = -1
self.pageButtonList = []
self.curPageIndex = 0
self.isLoaded = 0
self.xSafeBoxStart = 0
self.ySafeBoxStart = 0
self.__LoadWindow()
def __del__(self):
ui.ScriptWindow.__del__(self)
def Show(self):
self.__LoadWindow()
ui.ScriptWindow.Show(self)
def Destroy(self):
self.ClearDictionary()
self.dlgPickMoney.Destroy()
self.dlgPickMoney = None
self.dlgChangePassword.Destroy()
self.dlgChangePassword = None
self.tooltipItem = None
self.wndMoneySlot = None
self.wndMoney = None
self.wndBoard = None
self.wndItem = None
self.pageButtonList = []
def __LoadWindow(self):
if self.isLoaded == 1:
return
self.isLoaded = 1
pyScrLoader = ui.PythonScriptLoader()
pyScrLoader.LoadScriptFile(self, "UIScript/SafeboxWindow.py")
from _weakref import proxy
## Item
wndItem = ui.GridSlotWindow()
wndItem.SetParent(self)
wndItem.SetPosition(8, 35)
wndItem.SetSelectEmptySlotEvent(ui.__mem_func__(self.SelectEmptySlot))
wndItem.SetSelectItemSlotEvent(ui.__mem_func__(self.SelectItemSlot))
wndItem.SetUnselectItemSlotEvent(ui.__mem_func__(self.UseItemSlot))
wndItem.SetUseSlotEvent(ui.__mem_func__(self.UseItemSlot))
wndItem.SetOverInItemEvent(ui.__mem_func__(self.OverInItem))
wndItem.SetOverOutItemEvent(ui.__mem_func__(self.OverOutItem))
wndItem.Show()
## PickMoneyDialog
import uiPickMoney
dlgPickMoney = uiPickMoney.PickMoneyDialog()
dlgPickMoney.LoadDialog()
dlgPickMoney.SetAcceptEvent(ui.__mem_func__(self.OnPickMoney))
dlgPickMoney.Hide()
## ChangePasswrod
dlgChangePassword = ChangePasswordDialog()
dlgChangePassword.LoadDialog()
dlgChangePassword.Hide()
## Close Button
self.GetChild("TitleBar").SetCloseEvent(ui.__mem_func__(self.Close))
self.GetChild("ChangePasswordButton").SetEvent(ui.__mem_func__(self.OnChangePassword))
self.GetChild("ExitButton").SetEvent(ui.__mem_func__(self.Close))
self.wndItem = wndItem
self.dlgPickMoney = dlgPickMoney
self.dlgChangePassword = dlgChangePassword
self.wndBoard = self.GetChild("board")
#self.wndMoney = self.GetChild("Money")
#self.wndMoneySlot = self.GetChild("Money_Slot")
#self.wndMoneySlot.SetEvent(ui.__mem_func__(self.OpenPickMoneyDialog))
## Initialize
self.SetTableSize(3)
self.RefreshSafeboxMoney()
def OpenPickMoneyDialog(self):
if mouseModule.mouseController.isAttached():
attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
if player.SLOT_TYPE_INVENTORY == mouseModule.mouseController.GetAttachedType():
if player.ITEM_MONEY == mouseModule.mouseController.GetAttachedItemIndex():
net.SendSafeboxSaveMoneyPacket(mouseModule.mouseController.GetAttachedItemCount())
snd.PlaySound("sound/ui/money.wav")
mouseModule.mouseController.DeattachObject()
else:
curMoney = safebox.GetMoney()
if curMoney <= 0:
return
self.dlgPickMoney.Open(curMoney)
def ShowWindow(self, size):
(self.xSafeBoxStart, self.ySafeBoxStart, z) = player.GetMainCharacterPosition()
self.SetTableSize(size)
self.Show()
def __MakePageButton(self, pageCount):
self.curPageIndex = 0
self.pageButtonList = []
text = "I"
pos = -int(float(pageCount-1) / 2 * 52)
for i in range(pageCount):
button = ui.RadioButton()
button.SetParent(self)
button.SetUpVisual("d:/ymir work/ui/game/windows/tab_button_middle_01.sub")
button.SetOverVisual("d:/ymir work/ui/game/windows/tab_button_middle_02.sub")
button.SetDownVisual("d:/ymir work/ui/game/windows/tab_button_middle_03.sub")
button.SetWindowHorizontalAlignCenter()
button.SetWindowVerticalAlignBottom()
button.SetPosition(pos, 85)
button.SetText(text)
button.SetEvent(lambda arg=i: self.SelectPage(arg))
button.Show()
self.pageButtonList.append(button)
pos += 52
text += "I"
self.pageButtonList[0].Down()
def SelectPage(self, index):
self.curPageIndex = index
for btn in self.pageButtonList:
btn.SetUp()
self.pageButtonList[index].Down()
self.RefreshSafebox()
def __LocalPosToGlobalPos(self, local):
return self.curPageIndex * safebox.SAFEBOX_PAGE_SIZE + local
def SetTableSize(self, size):
pageCount = max(1, size // safebox.SAFEBOX_SLOT_Y_COUNT)
pageCount = min(3, pageCount)
size = safebox.SAFEBOX_SLOT_Y_COUNT
self.__MakePageButton(pageCount)
self.wndItem.ArrangeSlot(0, safebox.SAFEBOX_SLOT_X_COUNT, size, 32, 32, 0, 0)
self.wndItem.RefreshSlot()
self.wndItem.SetSlotBaseImage("d:/ymir work/ui/public/Slot_Base.sub", 1.0, 1.0, 1.0, 1.0)
wnd_height = 130 + 32 * size
self.wndBoard.SetSize(self.BOX_WIDTH, wnd_height)
self.SetSize(self.BOX_WIDTH, wnd_height)
self.UpdateRect()
def RefreshSafebox(self):
getItemID=safebox.GetItemID
getItemCount=safebox.GetItemCount
setItemID=self.wndItem.SetItemSlot
for i in range(safebox.SAFEBOX_PAGE_SIZE):
slotIndex = self.__LocalPosToGlobalPos(i)
itemCount = getItemCount(slotIndex)
if itemCount <= 1:
itemCount = 0
setItemID(i, getItemID(slotIndex), itemCount)
self.wndItem.RefreshSlot()
def RefreshSafeboxMoney(self):
pass
#self.wndMoney.SetText(str(safebox.GetMoney()))
def SetItemToolTip(self, tooltip):
self.tooltipItem = tooltip
def Close(self):
net.SendChatPacket("/safebox_close")
def CommandCloseSafebox(self):
if self.tooltipItem:
self.tooltipItem.HideToolTip()
self.dlgPickMoney.Close()
self.dlgChangePassword.Close()
self.Hide()
## Slot Event
def SelectEmptySlot(self, selectedSlotPos):
import constInfo
selectedSlotPos = self.__LocalPosToGlobalPos(selectedSlotPos)
if mouseModule.mouseController.isAttached():
attachedSlotType = mouseModule.mouseController.GetAttachedType()
attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
# MR-3: Auto-deactivate auto potions before moving out
# Deactivate inventory slot if it's an active auto potion before moving out
if attachedSlotType == player.SLOT_TYPE_INVENTORY:
itemVnum = player.GetItemIndex(attachedSlotPos)
if constInfo.IS_AUTO_POTION(itemVnum):
metinSocket = [player.GetItemMetinSocket(attachedSlotPos, j) for j in range(player.METIN_SOCKET_MAX_NUM)]
isActivated = (0 != int(metinSocket[0]))
if isActivated:
net.SendItemUsePacket(attachedSlotPos)
# MR-3: -- END OF -- Auto-deactivate auto potions before moving out
if player.SLOT_TYPE_SAFEBOX == attachedSlotType:
net.SendSafeboxItemMovePacket(attachedSlotPos, selectedSlotPos, 0)
#snd.PlaySound("sound/ui/drop.wav")
else:
attachedInvenType = player.SlotTypeToInvenType(attachedSlotType)
if player.RESERVED_WINDOW == attachedInvenType:
return
if player.ITEM_MONEY == mouseModule.mouseController.GetAttachedItemIndex():
net.SendSafeboxSaveMoneyPacket(mouseModule.mouseController.GetAttachedItemCount())
snd.PlaySound("sound/ui/money.wav")
else:
net.SendSafeboxCheckinPacket(attachedInvenType, attachedSlotPos, selectedSlotPos)
#snd.PlaySound("sound/ui/drop.wav")
mouseModule.mouseController.DeattachObject()
def SelectItemSlot(self, selectedSlotPos):
selectedSlotPos = self.__LocalPosToGlobalPos(selectedSlotPos)
if mouseModule.mouseController.isAttached():
attachedSlotType = mouseModule.mouseController.GetAttachedType()
if player.SLOT_TYPE_INVENTORY == attachedSlotType:
if player.ITEM_MONEY == mouseModule.mouseController.GetAttachedItemIndex():
net.SendSafeboxSaveMoneyPacket(mouseModule.mouseController.GetAttachedItemCount())
snd.PlaySound("sound/ui/money.wav")
else:
attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
#net.SendSafeboxCheckinPacket(attachedSlotPos, selectedSlotPos)
#snd.PlaySound("sound/ui/drop.wav")
mouseModule.mouseController.DeattachObject()
else:
curCursorNum = app.GetCursor()
if app.SELL == curCursorNum:
chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.SAFEBOX_SELL_DISABLE_SAFEITEM)
elif app.BUY == curCursorNum:
chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.SHOP_BUY_INFO)
else:
selectedItemID = safebox.GetItemID(selectedSlotPos)
mouseModule.mouseController.AttachObject(self, player.SLOT_TYPE_SAFEBOX, selectedSlotPos, selectedItemID)
snd.PlaySound("sound/ui/pick.wav")
def UseItemSlot(self, slotIndex):
mouseModule.mouseController.DeattachObject()
def __ShowToolTip(self, slotIndex):
if self.tooltipItem:
self.tooltipItem.SetSafeBoxItem(slotIndex)
def OverInItem(self, slotIndex):
slotIndex = self.__LocalPosToGlobalPos(slotIndex)
self.wndItem.SetUsableItem(False)
self.__ShowToolTip(slotIndex)
def OverOutItem(self):
self.wndItem.SetUsableItem(False)
if self.tooltipItem:
self.tooltipItem.HideToolTip()
def OnPickMoney(self, money):
mouseModule.mouseController.AttachMoney(self, player.SLOT_TYPE_SAFEBOX, money)
def OnChangePassword(self):
self.dlgChangePassword.Open()
def OnPressEscapeKey(self):
self.Close()
return True
def OnUpdate(self):
USE_SAFEBOX_LIMIT_RANGE = 1000
(x, y, z) = player.GetMainCharacterPosition()
if abs(x - self.xSafeBoxStart) > USE_SAFEBOX_LIMIT_RANGE or abs(y - self.ySafeBoxStart) > USE_SAFEBOX_LIMIT_RANGE:
self.Close()
class MallWindow(ui.ScriptWindow):
BOX_WIDTH = 176
def __init__(self):
ui.ScriptWindow.__init__(self)
self.tooltipItem = None
self.sellingSlotNumber = -1
self.pageButtonList = []
self.curPageIndex = 0
self.isLoaded = 0
self.xSafeBoxStart = 0
self.ySafeBoxStart = 0
self.__LoadWindow()
def __del__(self):
ui.ScriptWindow.__del__(self)
def Show(self):
self.__LoadWindow()
ui.ScriptWindow.Show(self)
def Destroy(self):
self.ClearDictionary()
self.tooltipItem = None
self.wndBoard = None
self.wndItem = None
self.pageButtonList = []
def __LoadWindow(self):
if self.isLoaded == 1:
return
self.isLoaded = 1
pyScrLoader = ui.PythonScriptLoader()
pyScrLoader.LoadScriptFile(self, "UIScript/MallWindow.py")
from _weakref import proxy
## Item
wndItem = ui.GridSlotWindow()
wndItem.SetParent(self)
wndItem.SetPosition(8, 35)
wndItem.SetSelectEmptySlotEvent(ui.__mem_func__(self.SelectEmptySlot))
wndItem.SetSelectItemSlotEvent(ui.__mem_func__(self.SelectItemSlot))
wndItem.SetUnselectItemSlotEvent(ui.__mem_func__(self.UseItemSlot))
wndItem.SetUseSlotEvent(ui.__mem_func__(self.UseItemSlot))
wndItem.SetOverInItemEvent(ui.__mem_func__(self.OverInItem))
wndItem.SetOverOutItemEvent(ui.__mem_func__(self.OverOutItem))
wndItem.Show()
## Close Button
self.GetChild("TitleBar").SetCloseEvent(ui.__mem_func__(self.Close))
self.GetChild("ExitButton").SetEvent(ui.__mem_func__(self.Close))
self.wndItem = wndItem
self.wndBoard = self.GetChild("board")
## Initialize
self.SetTableSize(3)
def ShowWindow(self, size):
(self.xSafeBoxStart, self.ySafeBoxStart, z) = player.GetMainCharacterPosition()
self.SetTableSize(size)
self.Show()
def SetTableSize(self, size):
pageCount = max(1, size // safebox.SAFEBOX_SLOT_Y_COUNT)
pageCount = min(3, pageCount)
size = safebox.SAFEBOX_SLOT_Y_COUNT
self.wndItem.ArrangeSlot(0, safebox.SAFEBOX_SLOT_X_COUNT, size, 32, 32, 0, 0)
self.wndItem.RefreshSlot()
self.wndItem.SetSlotBaseImage("d:/ymir work/ui/public/Slot_Base.sub", 1.0, 1.0, 1.0, 1.0)
self.wndBoard.SetSize(self.BOX_WIDTH, 82 + 32 * size)
self.SetSize(self.BOX_WIDTH, 85 + 32 * size)
self.UpdateRect()
def RefreshMall(self):
getItemID = safebox.GetMallItemID
getItemCount = safebox.GetMallItemCount
setItemID = self.wndItem.SetItemSlot
for i in range(safebox.GetMallSize()):
itemID = getItemID(i)
itemCount = getItemCount(i)
if itemCount <= 1:
itemCount = 0
setItemID(i, itemID, itemCount)
self.wndItem.RefreshSlot()
def SetItemToolTip(self, tooltip):
self.tooltipItem = tooltip
def Close(self):
net.SendChatPacket("/mall_close")
def CommandCloseMall(self):
if self.tooltipItem:
self.tooltipItem.HideToolTip()
self.Hide()
## Slot Event
def SelectEmptySlot(self, selectedSlotPos):
if mouseModule.mouseController.isAttached():
chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.MALL_CANNOT_INSERT)
mouseModule.mouseController.DeattachObject()
def SelectItemSlot(self, selectedSlotPos):
if mouseModule.mouseController.isAttached():
chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.MALL_CANNOT_INSERT)
mouseModule.mouseController.DeattachObject()
else:
curCursorNum = app.GetCursor()
selectedItemID = safebox.GetMallItemID(selectedSlotPos)
mouseModule.mouseController.AttachObject(self, player.SLOT_TYPE_MALL, selectedSlotPos, selectedItemID)
snd.PlaySound("sound/ui/pick.wav")
def UseItemSlot(self, slotIndex):
mouseModule.mouseController.DeattachObject()
def __ShowToolTip(self, slotIndex):
if self.tooltipItem:
self.tooltipItem.SetMallItem(slotIndex)
def OverInItem(self, slotIndex):
self.__ShowToolTip(slotIndex)
def OverOutItem(self):
self.wndItem.SetUsableItem(False)
if self.tooltipItem:
self.tooltipItem.HideToolTip()
def OnPressEscapeKey(self):
self.Close()
return True
def OnUpdate(self):
USE_SAFEBOX_LIMIT_RANGE = 1000
(x, y, z) = player.GetMainCharacterPosition()
if abs(x - self.xSafeBoxStart) > USE_SAFEBOX_LIMIT_RANGE or abs(y - self.ySafeBoxStart) > USE_SAFEBOX_LIMIT_RANGE:
self.Close()
if __name__ == "__main__":
import app
import wndMgr
import systemSetting
import mouseModule
import grp
import ui
import chr
import background
import player
#wndMgr.SetOutlineFlag(True)
app.SetMouseHandler(mouseModule.mouseController)
app.SetHairColorEnable(True)
wndMgr.SetMouseHandler(mouseModule.mouseController)
wndMgr.SetScreenSize(systemSetting.GetWidth(), systemSetting.GetHeight())
app.Create("METIN2 CLOSED BETA", systemSetting.GetWidth(), systemSetting.GetHeight(), 1)
mouseModule.mouseController.Create()
wnd = SafeboxWindow()
wnd.ShowWindow(1)
app.Loop()
-103
View File
@@ -1,103 +0,0 @@
import app
AUTOBAN_QUIZ_ANSWER = "ANSWER"
AUTOBAN_QUIZ_REFRESH = "REFRESH"
AUTOBAN_QUIZ_REST_TIME = "REST_TIME"
OPTION_SHADOW = "SHADOW"
#CUBE_TITLE = "Cube Window"
def LoadLocaleFile(srcFileName, localeDict):
localeDict["CUBE_INFO_TITLE"] = "Recipe"
localeDict["CUBE_REQUIRE_MATERIAL"] = "Requirements"
localeDict["CUBE_REQUIRE_MATERIAL_OR"] = "or"
try:
lines = pack_open(srcFileName, "r").readlines()
except IOError:
import dbg
dbg.LogBox("LoadUIScriptLocaleError(%(srcFileName)s)" % locals())
app.Abort()
for line in lines:
tokens = line[:-1].split("\t")
if len(tokens) >= 2:
localeDict[tokens[0]] = tokens[1]
else:
print((len(tokens), lines.index(line), line))
name = app.GetLocalePath()
LOCALE_UISCRIPT_PATH = "%s/ui/" % (name)
LOGIN_PATH = "%s/ui/login/" % (name)
EMPIRE_PATH = "%s/ui/empire/" % (name)
GUILD_PATH = "%s/ui/guild/" % (name)
SELECT_PATH = "%s/ui/select/" % (name)
WINDOWS_PATH = "%s/ui/windows/" % (name)
MAPNAME_PATH = "%s/ui/mapname/" % (name)
JOBDESC_WARRIOR_PATH = "%s/jobdesc_warrior.txt" % (name)
JOBDESC_ASSASSIN_PATH = "%s/jobdesc_assassin.txt" % (name)
JOBDESC_SURA_PATH = "%s/jobdesc_sura.txt" % (name)
JOBDESC_SHAMAN_PATH = "%s/jobdesc_shaman.txt" % (name)
EMPIREDESC_A = "%s/empiredesc_a.txt" % (name)
EMPIREDESC_B = "%s/empiredesc_b.txt" % (name)
EMPIREDESC_C = "%s/empiredesc_c.txt" % (name)
LOCALE_INTERFACE_FILE_NAME = "%s/locale_interface.txt" % (name)
LoadLocaleFile(LOCALE_INTERFACE_FILE_NAME, globals())
def LoadLocaleData():
"""
Reload all UI locale strings from locale_interface.txt
Called by app.ReloadLocale() when the user changes language.
Updates all locale-dependent paths and reloads locale_interface.txt.
This is the LAST Python module reloaded by the C++ reload chain,
so it fires localeInfo.FireReloadCallbacks() at the end to notify
all modules that both localeInfo and uiScriptLocale are fully loaded.
Returns:
True on success, False on failure
"""
try:
# Update all locale-dependent paths
global name, LOCALE_UISCRIPT_PATH, LOGIN_PATH, EMPIRE_PATH, GUILD_PATH, SELECT_PATH, WINDOWS_PATH, MAPNAME_PATH
global JOBDESC_WARRIOR_PATH, JOBDESC_ASSASSIN_PATH, JOBDESC_SURA_PATH, JOBDESC_SHAMAN_PATH
global EMPIREDESC_A, EMPIREDESC_B, EMPIREDESC_C, LOCALE_INTERFACE_FILE_NAME
name = app.GetLocalePath()
LOCALE_UISCRIPT_PATH = "%s/ui/" % (name)
LOGIN_PATH = "%s/ui/login/" % (name)
EMPIRE_PATH = "%s/ui/empire/" % (name)
GUILD_PATH = "%s/ui/guild/" % (name)
SELECT_PATH = "%s/ui/select/" % (name)
WINDOWS_PATH = "%s/ui/windows/" % (name)
MAPNAME_PATH = "%s/ui/mapname/" % (name)
JOBDESC_WARRIOR_PATH = "%s/jobdesc_warrior.txt" % (name)
JOBDESC_ASSASSIN_PATH = "%s/jobdesc_assassin.txt" % (name)
JOBDESC_SURA_PATH = "%s/jobdesc_sura.txt" % (name)
JOBDESC_SHAMAN_PATH = "%s/jobdesc_shaman.txt" % (name)
EMPIREDESC_A = "%s/empiredesc_a.txt" % (name)
EMPIREDESC_B = "%s/empiredesc_b.txt" % (name)
EMPIREDESC_C = "%s/empiredesc_c.txt" % (name)
LOCALE_INTERFACE_FILE_NAME = "%s/locale_interface.txt" % (name)
# Reload locale_interface.txt - this updates all UI strings
LoadLocaleFile(LOCALE_INTERFACE_FILE_NAME, globals())
# Fire reload callbacks now that BOTH modules are fully loaded
import localeInfo
localeInfo.FireReloadCallbacks()
return True
except Exception as e:
import dbg
dbg.TraceError("uiScriptLocale.LoadLocaleData failed: %s" % str(e))
return False
-139
View File
@@ -1,139 +0,0 @@
import ui
import player
import item
import wndMgr
import net
class SelectItemWindow(ui.ScriptWindow):
def __init__(self):
ui.ScriptWindow.__init__(self)
self.tooltipItem = None
self.inventorySlotPosDict = {}
self.LoadWindow()
def __del__(self):
ui.ScriptWindow.__del__(self)
def LoadWindow(self):
try:
PythonScriptLoader = ui.PythonScriptLoader()
PythonScriptLoader.LoadScriptFile(self, "UIScript/selectitemwindow.py")
except:
import exception
exception.Abort("ItemSelectWindow.LoadDialog.LoadObject")
try:
GetObject = self.GetChild
self.board = GetObject("board")
self.titleBar = GetObject("TitleBar")
self.itemSlot = GetObject("ItemSlot")
self.btnExit = GetObject("ExitButton")
except:
import exception
exception.Abort("ItemSelectWindow.LoadDialog.BindObject")
self.titleBar.SetCloseEvent(ui.__mem_func__(self.Close))
self.btnExit.SetEvent(ui.__mem_func__(self.Close))
self.itemSlot.SetSlotStyle(wndMgr.SLOT_STYLE_NONE)
self.itemSlot.SAFE_SetButtonEvent("LEFT", "EXIST", self.SelectItemSlot)
self.itemSlot.SetOverInItemEvent(ui.__mem_func__(self.OverInItem))
self.itemSlot.SetOverOutItemEvent(ui.__mem_func__(self.OverOutItem))
def Open(self):
self.RefreshSlot()
self.Show()
def Close(self):
wndMgr.OnceIgnoreMouseLeftButtonUpEvent()
net.SendSelectItemPacket(0)
self.Hide()
def SetItemToolTip(self, tooltipItem):
self.tooltipItem = tooltipItem
def SelectItemSlot(self, slotPos):
wndMgr.OnceIgnoreMouseLeftButtonUpEvent()
inventorySlotPos = self.inventorySlotPosDict[slotPos]
net.SendSelectItemPacket(inventorySlotPos)
self.Hide()
def SetTableSize(self, size):
SLOT_X_COUNT = 5
self.itemSlot.ArrangeSlot(0, SLOT_X_COUNT, size, 32, 32, 0, 0)
self.itemSlot.RefreshSlot()
self.itemSlot.SetSlotBaseImage("d:/ymir work/ui/public/Slot_Base.sub", 1.0, 1.0, 1.0, 1.0)
self.board.SetSize(self.board.GetWidth(), 76 + 32*size)
self.SetSize(self.board.GetWidth(), 76 + 32*size)
self.UpdateRect()
def RefreshSlot(self):
slotPos = 0
self.inventorySlotPosDict = {}
getItemVNum=player.GetItemIndex
getItemCount=player.GetItemCount
setItemVNum=self.itemSlot.SetItemSlot
for i in range(player.INVENTORY_PAGE_SIZE*2):
slotNumber = i
itemVNum = getItemVNum(slotNumber)
if 0 == itemVNum:
continue
if not item.IsMetin(itemVNum):
continue
itemGrade = player.GetItemGrade(slotNumber)
if itemGrade > 2:
continue
self.inventorySlotPosDict[slotPos] = i
slotPos += 1
if slotPos > 54:
break
itemCount = len(self.inventorySlotPosDict)
if itemCount < 15:
self.SetTableSize(3)
else:
lineCount = 3
lineCount += (itemCount - 15) // 5
if itemCount % 5:
lineCount += 1
self.SetTableSize(lineCount)
for selectWndPos, inventoryPos in list(self.inventorySlotPosDict.items()):
itemVNum = getItemVNum(inventoryPos)
itemCount = getItemCount(inventoryPos)
if itemCount <= 1:
itemCount = 0
setItemVNum(selectWndPos, itemVNum, itemCount)
self.itemSlot.RefreshSlot()
def OverOutItem(self):
if None != self.tooltipItem:
self.tooltipItem.HideToolTip()
def OverInItem(self, slotIndex):
if None != self.tooltipItem:
inventorySlotPos = self.inventorySlotPosDict[slotIndex]
self.tooltipItem.SetInventoryItem(inventorySlotPos)
-213
View File
@@ -1,213 +0,0 @@
import app
import ui
import localeInfo
import uiScriptLocale
FILE_NAME_LEN = 20
DEFAULT_THEMA = ""
def _RebuildLocaleStrings():
global DEFAULT_THEMA
DEFAULT_THEMA = localeInfo.MUSIC_METIN2_DEFAULT_THEMA
_RebuildLocaleStrings()
localeInfo.RegisterReloadCallback(_RebuildLocaleStrings)
class Item(ui.ListBoxEx.Item):
def __init__(self, fileName):
ui.ListBoxEx.Item.__init__(self)
self.canLoad=0
self.text=fileName
self.textLine=self.__CreateTextLine(fileName[:FILE_NAME_LEN])
def __del__(self):
ui.ListBoxEx.Item.__del__(self)
def GetText(self):
return self.text
def SetSize(self, width, height):
ui.ListBoxEx.Item.SetSize(self, 6*len(self.textLine.GetText()) + 4, height)
def __CreateTextLine(self, fileName):
textLine=ui.TextLine()
textLine.SetParent(self)
if app.IsRTL():
textLine.SetPosition(6*len(fileName) + 6, 0)
else:
textLine.SetPosition(0, 0)
textLine.SetText(fileName)
textLine.Show()
return textLine
class PopupDialog(ui.ScriptWindow):
def __init__(self, parent):
print("NEW POPUP WINDOW ----------------------------------------------------------------------------")
ui.ScriptWindow.__init__(self)
self.__Load()
self.__Bind()
def __del__(self):
ui.ScriptWindow.__del__(self)
print("---------------------------------------------------------------------------- DELETE POPUP WINDOW")
def __Load(self):
try:
pyScrLoader = ui.PythonScriptLoader()
pyScrLoader.LoadScriptFile(self, "UIScript/PopupDialog.py")
except:
import exception
exception.Abort("PopupDialog.__Load")
def __Bind(self):
try:
self.textLine=self.GetChild("message")
self.okButton=self.GetChild("accept")
except:
import exception
exception.Abort("PopupDialog.__Bind")
self.okButton.SAFE_SetEvent(self.__OnOK)
def Open(self, msg):
self.textLine.SetText(msg)
self.SetCenterPosition()
self.Show()
self.SetTop()
def __OnOK(self):
self.Hide()
class FileListDialog(ui.ScriptWindow):
def __init__(self):
print("NEW LIST DIALOG ----------------------------------------------------------------------------")
ui.ScriptWindow.__init__(self)
self.isLoaded=0
self.selectEvent=None
self.fileListBox=None
def __del__(self):
ui.ScriptWindow.__del__(self)
print("---------------------------------------------------------------------------- DELETE LIST DIALOG")
def Show(self):
if self.isLoaded==0:
self.isLoaded=1
self.__Load()
ui.ScriptWindow.Show(self)
def Open(self):
self.Show()
self.SetCenterPosition()
self.SetTop()
if self.fileListBox.IsEmpty():
self.__PopupMessage(localeInfo.MUSIC_EMPTY_MUSIC_LIST)
def Close(self):
self.popupDialog.Hide()
self.Hide()
def OnPressEscapeKey(self):
self.Close()
return True
def SAFE_SetSelectEvent(self, event):
self.selectEvent=ui.__mem_func__(event)
def __CreateFileListBox(self):
fileListBox=ui.ListBoxEx()
fileListBox.SetParent(self)
if app.IsRTL():
fileListBox.SetPosition( self.GetWidth() - fileListBox.GetWidth() - 10, 50)
else:
fileListBox.SetPosition(15, 50)
fileListBox.Show()
return fileListBox
def __Load(self):
self.popupDialog=PopupDialog(self)
if app.IsRTL():
self.__Load_LoadScript(uiScriptLocale.LOCALE_UISCRIPT_PATH + "MusicListWindow.py")
else:
self.__Load_LoadScript("UIScript/MusicListWindow.py")
self.__Load_BindObject()
self.refreshButton.SAFE_SetEvent(self.__OnRefresh)
self.cancelButton.SAFE_SetEvent(self.__OnCancel)
self.okButton.SAFE_SetEvent(self.__OnOK)
self.board.SetCloseEvent(ui.__mem_func__(self.__OnCancel))
self.UpdateRect()
self.__RefreshFileList()
def __Load_LoadScript(self, fileName):
try:
pyScrLoader = ui.PythonScriptLoader()
pyScrLoader.LoadScriptFile(self, fileName)
except:
import exception
exception.Abort("MusicListBox.__Load")
def __Load_BindObject(self):
try:
self.fileListBox=self.__CreateFileListBox()
self.fileListBox.SetScrollBar(self.GetChild("ScrollBar"))
self.board=self.GetChild("board")
self.okButton=self.GetChild("ok")
self.cancelButton=self.GetChild("cancel")
self.refreshButton=self.GetChild("refresh")
self.popupText = self.popupDialog.GetChild("message")
except:
import exception
exception.Abort("MusicListBox.__Bind")
def __PopupMessage(self, msg):
self.popupDialog.Open(msg)
def __OnOK(self):
selItem=self.fileListBox.GetSelectedItem()
if selItem:
if self.selectEvent:
self.selectEvent(selItem.GetText())
self.Hide()
else:
self.__PopupMessage(localeInfo.MUSIC_NOT_SELECT_MUSIC)
def __OnCancel(self):
self.Hide()
def __OnRefresh(self):
self.__RefreshFileList()
def __RefreshFileList(self):
self.__ClearFileList()
self.__AppendFile(DEFAULT_THEMA)
self.__AppendFileList("mp3")
def __ClearFileList(self):
self.fileListBox.RemoveAllItems()
def __AppendFileList(self, filter):
fileNameList=app.GetFileList("BGM/*."+filter)
for fileName in fileNameList:
self.__AppendFile(fileName)
def __AppendFile(self, fileName):
self.fileListBox.AppendItem(Item(fileName))
-495
View File
@@ -1,495 +0,0 @@
import net
import player
import item
import snd
import shop
import net
import wndMgr
import app
import chat
import ui
import uiCommon
import mouseModule
import localeInfo
import constInfo
###################################################################################################
## Shop
class ShopDialog(ui.ScriptWindow):
def __init__(self):
ui.ScriptWindow.__init__(self)
self.tooltipItem = 0
self.xShopStart = 0
self.yShopStart = 0
self.questionDialog = None
self.popup = None
self.itemBuyQuestionDialog = None
def __del__(self):
ui.ScriptWindow.__del__(self)
def __GetRealIndex(self, i):
return self.tabIdx * shop.SHOP_SLOT_COUNT + i
def Refresh(self):
getItemID=shop.GetItemID
getItemCount=shop.GetItemCount
setItemID=self.itemSlotWindow.SetItemSlot
for i in range(shop.SHOP_SLOT_COUNT):
idx = self.__GetRealIndex(i)
itemCount = getItemCount(idx)
if itemCount <= 1:
itemCount = 0
setItemID(i, getItemID(idx), itemCount)
wndMgr.RefreshSlot(self.itemSlotWindow.GetWindowHandle())
def SetItemData(self, pos, itemID, itemCount, itemPrice):
shop.SetItemData(pos, itemID, itemCount, itemPrice)
def LoadDialog(self):
try:
PythonScriptLoader = ui.PythonScriptLoader()
PythonScriptLoader.LoadScriptFile(self, "UIScript/shopdialog.py")
except:
import exception
exception.Abort("ShopDialog.LoadDialog.LoadObject")
smallTab1 = None
smallTab2 = None
smallTab3 = None
middleTab1 = None
middleTab2 = None
try:
GetObject = self.GetChild
self.itemSlotWindow = GetObject("ItemSlot")
self.btnBuy = GetObject("BuyButton")
self.btnSell = GetObject("SellButton")
self.btnClose = GetObject("CloseButton")
self.titleBar = GetObject("TitleBar")
middleTab1 = GetObject("MiddleTab1")
middleTab2 = GetObject("MiddleTab2")
smallTab1 = GetObject("SmallTab1")
smallTab2 = GetObject("SmallTab2")
smallTab3 = GetObject("SmallTab3")
except:
import exception
exception.Abort("ShopDialog.LoadDialog.BindObject")
self.itemSlotWindow.SetSlotStyle(wndMgr.SLOT_STYLE_NONE)
self.itemSlotWindow.SAFE_SetButtonEvent("LEFT", "EMPTY", self.SelectEmptySlot)
self.itemSlotWindow.SAFE_SetButtonEvent("LEFT", "EXIST", self.SelectItemSlot)
self.itemSlotWindow.SAFE_SetButtonEvent("RIGHT", "EXIST", self.UnselectItemSlot)
self.itemSlotWindow.SetOverInItemEvent(ui.__mem_func__(self.OverInItem))
self.itemSlotWindow.SetOverOutItemEvent(ui.__mem_func__(self.OverOutItem))
self.btnBuy.SetToggleUpEvent(ui.__mem_func__(self.CancelShopping))
self.btnBuy.SetToggleDownEvent(ui.__mem_func__(self.OnBuy))
self.btnSell.SetToggleUpEvent(ui.__mem_func__(self.CancelShopping))
self.btnSell.SetToggleDownEvent(ui.__mem_func__(self.OnSell))
self.btnClose.SetEvent(ui.__mem_func__(self.AskClosePrivateShop))
self.titleBar.SetCloseEvent(ui.__mem_func__(self.Close))
self.smallRadioButtonGroup = ui.RadioButtonGroup.Create([[smallTab1, lambda : self.OnClickTabButton(0), None], [smallTab2, lambda : self.OnClickTabButton(1), None], [smallTab3, lambda : self.OnClickTabButton(2), None]])
self.middleRadioButtonGroup = ui.RadioButtonGroup.Create([[middleTab1, lambda : self.OnClickTabButton(0), None], [middleTab2, lambda : self.OnClickTabButton(1), None]])
self.__HideMiddleTabs()
self.__HideSmallTabs()
self.tabIdx = 0
self.coinType = shop.SHOP_COIN_TYPE_GOLD
self.Refresh()
def __ShowBuySellButton(self):
self.btnBuy.Show()
self.btnSell.Show()
def __ShowMiddleTabs(self):
self.middleRadioButtonGroup.Show()
def __ShowSmallTabs(self):
self.smallRadioButtonGroup.Show()
def __HideBuySellButton(self):
self.btnBuy.Hide()
self.btnSell.Hide()
def __HideMiddleTabs(self):
self.middleRadioButtonGroup.Hide()
def __HideSmallTabs(self):
self.smallRadioButtonGroup.Hide()
def __SetTabNames(self):
if shop.GetTabCount() == 2:
self.middleRadioButtonGroup.SetText(0, shop.GetTabName(0))
self.middleRadioButtonGroup.SetText(1, shop.GetTabName(1))
elif shop.GetTabCount() == 3:
self.smallRadioButtonGroup.SetText(0, shop.GetTabName(0))
self.smallRadioButtonGroup.SetText(1, shop.GetTabName(1))
self.smallRadioButtonGroup.SetText(2, shop.GetTabName(2))
def Destroy(self):
self.Close()
self.ClearDictionary()
self.tooltipItem = 0
self.itemSlotWindow = 0
self.btnBuy = 0
self.btnSell = 0
self.btnClose = 0
self.titleBar = 0
self.questionDialog = None
self.popup = None
def Open(self, vid):
isPrivateShop = False
isMainPlayerPrivateShop = False
import chr
if chr.IsNPC(vid):
isPrivateShop = False
else:
isPrivateShop = True
if player.IsMainCharacterIndex(vid):
isMainPlayerPrivateShop = True
self.btnBuy.Hide()
self.btnSell.Hide()
self.btnClose.Show()
else:
isMainPlayerPrivateShop = False
self.btnBuy.Show()
self.btnSell.Show()
self.btnClose.Hide()
shop.Open(isPrivateShop, isMainPlayerPrivateShop)
self.tabIdx = 0
if isPrivateShop:
self.__HideMiddleTabs()
self.__HideSmallTabs()
else:
if shop.GetTabCount() == 1:
self.__ShowBuySellButton()
self.__HideMiddleTabs()
self.__HideSmallTabs()
elif shop.GetTabCount() == 2:
self.__HideBuySellButton()
self.__ShowMiddleTabs()
self.__HideSmallTabs()
self.__SetTabNames()
self.middleRadioButtonGroup.OnClick(0)
elif shop.GetTabCount() == 3:
self.__HideBuySellButton()
self.__HideMiddleTabs()
self.__ShowSmallTabs()
self.__SetTabNames()
self.middleRadioButtonGroup.OnClick(1)
self.Refresh()
self.SetTop()
self.Show()
(self.xShopStart, self.yShopStart, z) = player.GetMainCharacterPosition()
def Close(self):
if self.itemBuyQuestionDialog:
self.itemBuyQuestionDialog.Close()
self.itemBuyQuestionDialog = None
constInfo.SET_ITEM_QUESTION_DIALOG_STATUS(0)
if self.questionDialog:
self.OnCloseQuestionDialog()
shop.Close()
net.SendShopEndPacket()
self.CancelShopping()
self.tooltipItem.HideToolTip()
self.Hide()
def GetIndexFromSlotPos(self, slotPos):
return self.tabIdx * shop.SHOP_SLOT_COUNT + slotPos
def OnClickTabButton(self, idx):
self.tabIdx = idx
self.Refresh()
def AskClosePrivateShop(self):
questionDialog = uiCommon.QuestionDialog()
questionDialog.SetText(localeInfo.PRIVATE_SHOP_CLOSE_QUESTION)
questionDialog.SetAcceptEvent(ui.__mem_func__(self.OnClosePrivateShop))
questionDialog.SetCancelEvent(ui.__mem_func__(self.OnCloseQuestionDialog))
questionDialog.Open()
self.questionDialog = questionDialog
constInfo.SET_ITEM_QUESTION_DIALOG_STATUS(1)
return True
def OnClosePrivateShop(self):
net.SendChatPacket("/close_shop")
self.OnCloseQuestionDialog()
return True
def OnPressEscapeKey(self):
self.Close()
return True
def OnPressExitKey(self):
self.Close()
return True
def OnBuy(self):
chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.SHOP_BUY_INFO)
app.SetCursor(app.BUY)
self.btnSell.SetUp()
def OnSell(self):
chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.SHOP_SELL_INFO)
app.SetCursor(app.SELL)
self.btnBuy.SetUp()
def CancelShopping(self):
self.btnBuy.SetUp()
self.btnSell.SetUp()
app.SetCursor(app.NORMAL)
def __OnClosePopupDialog(self):
self.pop = None
constInfo.SET_ITEM_QUESTION_DIALOG_STATUS(0)
## 용혼석 팔리는 기능 추가.
def SellAttachedItem(self):
if shop.IsPrivateShop():
mouseModule.mouseController.DeattachObject()
return
attachedSlotType = mouseModule.mouseController.GetAttachedType()
attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
attachedCount = mouseModule.mouseController.GetAttachedItemCount()
attachedItemIndex = mouseModule.mouseController.GetAttachedItemIndex()
# if player.SLOT_TYPE_INVENTORY == attachedSlotType or player.SLOT_TYPE_DRAGON_SOUL_INVENTORY == attachedSlotType:
if player.SLOT_TYPE_INVENTORY == attachedSlotType:
itemIndex = player.GetItemIndex(attachedSlotPos)
item.SelectItem(itemIndex)
if item.IsAntiFlag(item.ANTIFLAG_SELL):
popup = uiCommon.PopupDialog()
popup.SetText(localeInfo.SHOP_CANNOT_SELL_ITEM)
popup.SetAcceptEvent(self.__OnClosePopupDialog)
popup.Open()
self.popup = popup
return
itemtype = player.INVENTORY
if player.SLOT_TYPE_DRAGON_SOUL_INVENTORY == attachedSlotType:
itemtype = player.DRAGON_SOUL_INVENTORY
# if player.IsValuableItem(itemtype, attachedSlotPos):
if player.IsValuableItem(attachedSlotPos):
itemPrice = item.GetISellItemPrice()
if item.Is1GoldItem():
itemPrice = attachedCount // itemPrice // 5
else:
itemPrice = itemPrice * max(1, attachedCount) // 5
itemName = item.GetItemName()
questionDialog = uiCommon.QuestionDialog()
questionDialog.SetText(localeInfo.DO_YOU_SELL_ITEM(itemName, attachedCount, itemPrice))
questionDialog.SetAcceptEvent(lambda arg1=attachedSlotPos, arg2=attachedCount, arg3 = itemtype: self.OnSellItem(arg1, arg2, arg3))
questionDialog.SetCancelEvent(ui.__mem_func__(self.OnCloseQuestionDialog))
questionDialog.Open()
self.questionDialog = questionDialog
constInfo.SET_ITEM_QUESTION_DIALOG_STATUS(1)
else:
self.OnSellItem(attachedSlotPos, attachedCount, itemtype)
else:
snd.PlaySound("sound/ui/loginfail.wav")
mouseModule.mouseController.DeattachObject()
def OnSellItem(self, slotPos, count, itemtype):
net.SendShopSellPacketNew(slotPos, count, itemtype)
snd.PlaySound("sound/ui/money.wav")
self.OnCloseQuestionDialog()
def OnCloseQuestionDialog(self):
if not self.questionDialog:
return
self.questionDialog.Close()
self.questionDialog = None
constInfo.SET_ITEM_QUESTION_DIALOG_STATUS(0)
def SelectEmptySlot(self, selectedSlotPos):
isAttached = mouseModule.mouseController.isAttached()
if isAttached:
self.SellAttachedItem()
def UnselectItemSlot(self, selectedSlotPos):
if constInfo.GET_ITEM_QUESTION_DIALOG_STATUS() == 1:
return
if shop.IsPrivateShop():
self.AskBuyItem(selectedSlotPos)
else:
net.SendShopBuyPacket(self.__GetRealIndex(selectedSlotPos))
def SelectItemSlot(self, selectedSlotPos):
if constInfo.GET_ITEM_QUESTION_DIALOG_STATUS() == 1:
return
isAttached = mouseModule.mouseController.isAttached()
selectedSlotPos = self.__GetRealIndex(selectedSlotPos)
if isAttached:
self.SellAttachedItem()
else:
if True == shop.IsMainPlayerPrivateShop():
return
curCursorNum = app.GetCursor()
if app.BUY == curCursorNum:
self.AskBuyItem(selectedSlotPos)
elif app.SELL == curCursorNum:
chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.SHOP_SELL_INFO)
else:
selectedItemID = shop.GetItemID(selectedSlotPos)
itemCount = shop.GetItemCount(selectedSlotPos)
type = player.SLOT_TYPE_SHOP
if shop.IsPrivateShop():
type = player.SLOT_TYPE_PRIVATE_SHOP
mouseModule.mouseController.AttachObject(self, type, selectedSlotPos, selectedItemID, itemCount)
mouseModule.mouseController.SetCallBack("INVENTORY", ui.__mem_func__(self.DropToInventory))
snd.PlaySound("sound/ui/pick.wav")
def DropToInventory(self):
attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
self.AskBuyItem(attachedSlotPos)
def AskBuyItem(self, slotPos):
slotPos = self.__GetRealIndex(slotPos)
itemIndex = shop.GetItemID(slotPos)
itemPrice = shop.GetItemPrice(slotPos)
itemCount = shop.GetItemCount(slotPos)
item.SelectItem(itemIndex)
itemName = item.GetItemName()
itemBuyQuestionDialog = uiCommon.QuestionDialog()
itemBuyQuestionDialog.SetText(localeInfo.DO_YOU_BUY_ITEM(itemName, itemCount, localeInfo.NumberToMoneyString(itemPrice)))
itemBuyQuestionDialog.SetAcceptEvent(lambda arg=True: self.AnswerBuyItem(arg))
itemBuyQuestionDialog.SetCancelEvent(lambda arg=False: self.AnswerBuyItem(arg))
itemBuyQuestionDialog.Open()
itemBuyQuestionDialog.pos = slotPos
self.itemBuyQuestionDialog = itemBuyQuestionDialog
constInfo.SET_ITEM_QUESTION_DIALOG_STATUS(1)
def AnswerBuyItem(self, flag):
if flag:
pos = self.itemBuyQuestionDialog.pos
net.SendShopBuyPacket(pos)
self.itemBuyQuestionDialog.Close()
self.itemBuyQuestionDialog = None
constInfo.SET_ITEM_QUESTION_DIALOG_STATUS(0)
def SetItemToolTip(self, tooltipItem):
self.tooltipItem = tooltipItem
def OverInItem(self, slotIndex):
slotIndex = self.__GetRealIndex(slotIndex)
if mouseModule.mouseController.isAttached():
return
if 0 != self.tooltipItem:
if shop.SHOP_COIN_TYPE_GOLD == shop.GetTabCoinType(self.tabIdx):
self.tooltipItem.SetShopItem(slotIndex)
else:
self.tooltipItem.SetShopItemBySecondaryCoin(slotIndex)
def OverOutItem(self):
if 0 != self.tooltipItem:
self.tooltipItem.HideToolTip()
def OnUpdate(self):
USE_SHOP_LIMIT_RANGE = 1000
(x, y, z) = player.GetMainCharacterPosition()
if abs(x - self.xShopStart) > USE_SHOP_LIMIT_RANGE or abs(y - self.yShopStart) > USE_SHOP_LIMIT_RANGE:
self.Close()
class MallPageDialog(ui.ScriptWindow):
def __init__(self):
ui.ScriptWindow.__init__(self)
def __del__(self):
ui.ScriptWindow.__del__(self)
def Destroy(self):
self.ClearDictionary()
def Open(self):
scriptLoader = ui.PythonScriptLoader()
scriptLoader.LoadScriptFile(self, "uiscript/mallpagedialog.py")
self.GetChild("titlebar").SetCloseEvent(ui.__mem_func__(self.Close))
(x, y)=self.GetGlobalPosition()
x+=10
y+=30
MALL_PAGE_WIDTH = 600
MALL_PAGE_HEIGHT = 480
app.ShowWebPage(
"http://metin2.co.kr/08_mall/game_mall/login_fail.htm",
(x, y, x+MALL_PAGE_WIDTH, y+MALL_PAGE_HEIGHT))
self.Lock()
self.Show()
def Close(self):
app.HideWebPage()
self.Unlock()
self.Hide()
def OnPressEscapeKey(self):
self.Close()
return True
-179
View File
@@ -1,179 +0,0 @@
import net
import app
import ui
import uiOption
import uiSystemOption
import uiGameOption
import uiScriptLocale
import networkModule
import constInfo
import localeInfo
SYSTEM_MENU_FOR_PORTAL = False
###################################################################################################
## System
class SystemDialog(ui.ScriptWindow):
def __init__(self):
ui.ScriptWindow.__init__(self)
self.__Initialize()
def __Initialize(self):
self.eventOpenHelpWindow = None
self.systemOptionDlg = None
self.gameOptionDlg = None
def LoadDialog(self):
if SYSTEM_MENU_FOR_PORTAL:
self.__LoadSystemMenu_ForPortal()
else:
self.__LoadSystemMenu_Default()
def __LoadSystemMenu_Default(self):
pyScrLoader = ui.PythonScriptLoader()
pyScrLoader.LoadScriptFile(self, "uiscript/systemdialog.py")
self.GetChild("system_option_button").SAFE_SetEvent(self.__ClickSystemOptionButton)
self.GetChild("game_option_button").SAFE_SetEvent(self.__ClickGameOptionButton)
self.GetChild("change_button").SAFE_SetEvent(self.__ClickChangeCharacterButton)
self.GetChild("logout_button").SAFE_SetEvent(self.__ClickLogOutButton)
self.GetChild("exit_button").SAFE_SetEvent(self.__ClickExitButton)
self.GetChild("help_button").SAFE_SetEvent(self.__ClickHelpButton)
self.GetChild("cancel_button").SAFE_SetEvent(self.Close)
self.GetChild("mall_button").SAFE_SetEvent(self.__ClickInGameShopButton)
def __LoadSystemMenu_ForPortal(self):
pyScrLoader = ui.PythonScriptLoader()
pyScrLoader.LoadScriptFile(self, "uiscript/systemdialog_forportal.py")
self.GetChild("system_option_button").SAFE_SetEvent(self.__ClickSystemOptionButton)
self.GetChild("game_option_button").SAFE_SetEvent(self.__ClickGameOptionButton)
self.GetChild("change_button").SAFE_SetEvent(self.__ClickChangeCharacterButton)
self.GetChild("exit_button").SAFE_SetEvent(self.__ClickExitButton)
self.GetChild("help_button").SAFE_SetEvent(self.__ClickHelpButton)
self.GetChild("cancel_button").SAFE_SetEvent(self.Close)
def Destroy(self):
self.ClearDictionary()
if self.gameOptionDlg:
self.gameOptionDlg.Destroy()
if self.systemOptionDlg:
self.systemOptionDlg.Destroy()
self.__Initialize()
def SetOpenHelpWindowEvent(self, event):
self.eventOpenHelpWindow = event
def OpenDialog(self):
self.Show()
def __ClickChangeCharacterButton(self):
self.Close()
net.ExitGame()
def __OnClosePopupDialog(self):
self.popup = None
def __ClickLogOutButton(self):
if SYSTEM_MENU_FOR_PORTAL:
if app.loggined:
self.Close()
net.ExitApplication()
else:
self.Close()
net.LogOutGame()
else:
self.Close()
net.LogOutGame()
def __ClickExitButton(self):
self.Close()
net.ExitApplication()
def __ClickSystemOptionButton(self):
self.Close()
if not self.systemOptionDlg:
self.systemOptionDlg = uiSystemOption.OptionDialog()
self.systemOptionDlg.Show()
def __ClickGameOptionButton(self):
self.Close()
if not self.gameOptionDlg:
self.gameOptionDlg = uiGameOption.OptionDialog()
self.gameOptionDlg.Show()
def __ClickHelpButton(self):
self.Close()
if None != self.eventOpenHelpWindow:
self.eventOpenHelpWindow()
def __ClickInGameShopButton(self):
self.Close()
net.SendChatPacket("/in_game_mall")
def Close(self):
self.Hide()
return True
def OnBlockMode(self, mode):
uiGameOption.blockMode = mode
if self.gameOptionDlg:
self.gameOptionDlg.OnBlockMode(mode)
#self.optionDialog.OnBlockMode(mode)
def OnChangePKMode(self):
if self.gameOptionDlg:
self.gameOptionDlg.OnChangePKMode()
#self.optionDialog.OnChangePKMode()
def OnPressExitKey(self):
self.Close()
return True
def OnPressEscapeKey(self):
self.Close()
return True
if __name__ == "__main__":
import app
import wndMgr
import systemSetting
import mouseModule
import grp
import ui
import chr
import background
import player
#wndMgr.SetOutlineFlag(True)
app.SetMouseHandler(mouseModule.mouseController)
app.SetHairColorEnable(True)
wndMgr.SetMouseHandler(mouseModule.mouseController)
wndMgr.SetScreenSize(systemSetting.GetWidth(), systemSetting.GetHeight())
app.Create("METIN2 CLOSED BETA", systemSetting.GetWidth(), systemSetting.GetHeight(), 1)
mouseModule.mouseController.Create()
wnd = SystemDialog()
wnd.LoadDialog()
wnd.Show()
app.Loop()
-256
View File
@@ -1,256 +0,0 @@
import dbg
import ui
import snd
import systemSetting
import net
import chat
import app
import localeInfo
import constInfo
import chrmgr
import player
import musicInfo
import uiSelectMusic
import background
MUSIC_FILENAME_MAX_LEN = 25
blockMode = 0
class OptionDialog(ui.ScriptWindow):
def __init__(self):
ui.ScriptWindow.__init__(self)
self.__Initialize()
self.__Load()
def __del__(self):
ui.ScriptWindow.__del__(self)
print(" -------------------------------------- DELETE SYSTEM OPTION DIALOG")
def __Initialize(self):
self.tilingMode = 0
self.titleBar = 0
self.changeMusicButton = 0
self.selectMusicFile = 0
self.ctrlMusicVolume = 0
self.ctrlSoundVolume = 0
self.musicListDlg = 0
self.tilingApplyButton = 0
self.cameraModeButtonList = []
self.fogModeButtonList = []
self.tilingModeButtonList = []
self.ctrlShadowQuality = 0
def Destroy(self):
self.ClearDictionary()
self.__Initialize()
print(" -------------------------------------- DESTROY SYSTEM OPTION DIALOG")
def __Load_LoadScript(self, fileName):
try:
pyScriptLoader = ui.PythonScriptLoader()
pyScriptLoader.LoadScriptFile(self, fileName)
except:
import exception
exception.Abort("System.OptionDialog.__Load_LoadScript")
def __Load_BindObject(self):
try:
GetObject = self.GetChild
self.titleBar = GetObject("titlebar")
self.selectMusicFile = GetObject("bgm_file")
self.changeMusicButton = GetObject("bgm_button")
self.ctrlMusicVolume = GetObject("music_volume_controller")
self.ctrlSoundVolume = GetObject("sound_volume_controller")
self.cameraModeButtonList.append(GetObject("camera_short"))
self.cameraModeButtonList.append(GetObject("camera_long"))
self.fogModeButtonList.append(GetObject("fog_level0"))
self.fogModeButtonList.append(GetObject("fog_level1"))
self.fogModeButtonList.append(GetObject("fog_level2"))
self.tilingModeButtonList.append(GetObject("tiling_cpu"))
self.tilingModeButtonList.append(GetObject("tiling_gpu"))
self.tilingApplyButton=GetObject("tiling_apply")
#self.ctrlShadowQuality = GetObject("shadow_bar")
except:
import exception
exception.Abort("OptionDialog.__Load_BindObject")
def __Load(self):
self.__Load_LoadScript("uiscript/systemoptiondialog.py")
self.__Load_BindObject()
self.SetCenterPosition()
self.titleBar.SetCloseEvent(ui.__mem_func__(self.Close))
self.ctrlMusicVolume.SetSliderPos(float(systemSetting.GetMusicVolume()))
self.ctrlMusicVolume.SetEvent(ui.__mem_func__(self.OnChangeMusicVolume))
self.ctrlSoundVolume.SetSliderPos(float(systemSetting.GetSoundVolume()))
self.ctrlSoundVolume.SetEvent(ui.__mem_func__(self.OnChangeSoundVolume))
# self.ctrlShadowQuality.SetSliderPos(float(systemSetting.GetShadowLevel()) / 5.0)
# self.ctrlShadowQuality.SetEvent(ui.__mem_func__(self.OnChangeShadowQuality))
self.changeMusicButton.SAFE_SetEvent(self.__OnClickChangeMusicButton)
self.cameraModeButtonList[0].SAFE_SetEvent(self.__OnClickCameraModeShortButton)
self.cameraModeButtonList[1].SAFE_SetEvent(self.__OnClickCameraModeLongButton)
self.fogModeButtonList[0].SAFE_SetEvent(self.__OnClickFogModeLevel0Button)
self.fogModeButtonList[1].SAFE_SetEvent(self.__OnClickFogModeLevel1Button)
self.fogModeButtonList[2].SAFE_SetEvent(self.__OnClickFogModeLevel2Button)
self.tilingModeButtonList[0].SAFE_SetEvent(self.__OnClickTilingModeCPUButton)
self.tilingModeButtonList[1].SAFE_SetEvent(self.__OnClickTilingModeGPUButton)
self.tilingApplyButton.SAFE_SetEvent(self.__OnClickTilingApplyButton)
self.__SetCurTilingMode()
# MR-14: Fog update by Alaric
self.__ClickRadioButton(self.fogModeButtonList, systemSetting.GetFogLevel())
# MR-14: -- END OF -- Fog update by Alaric
self.__ClickRadioButton(self.cameraModeButtonList, constInfo.GET_CAMERA_MAX_DISTANCE_INDEX())
if musicInfo.fieldMusic==musicInfo.METIN2THEMA:
self.selectMusicFile.SetText(uiSelectMusic.DEFAULT_THEMA)
else:
self.selectMusicFile.SetText(musicInfo.fieldMusic[:MUSIC_FILENAME_MAX_LEN])
def __OnClickTilingModeCPUButton(self):
self.__NotifyChatLine(localeInfo.SYSTEM_OPTION_CPU_TILING_1)
self.__NotifyChatLine(localeInfo.SYSTEM_OPTION_CPU_TILING_2)
self.__NotifyChatLine(localeInfo.SYSTEM_OPTION_CPU_TILING_3)
self.__SetTilingMode(0)
def __OnClickTilingModeGPUButton(self):
self.__NotifyChatLine(localeInfo.SYSTEM_OPTION_GPU_TILING_1)
self.__NotifyChatLine(localeInfo.SYSTEM_OPTION_GPU_TILING_2)
self.__NotifyChatLine(localeInfo.SYSTEM_OPTION_GPU_TILING_3)
self.__SetTilingMode(1)
def __OnClickTilingApplyButton(self):
self.__NotifyChatLine(localeInfo.SYSTEM_OPTION_TILING_EXIT)
if 0==self.tilingMode:
background.EnableSoftwareTiling(1)
else:
background.EnableSoftwareTiling(0)
net.ExitGame()
def __OnClickChangeMusicButton(self):
if not self.musicListDlg:
self.musicListDlg=uiSelectMusic.FileListDialog()
self.musicListDlg.SAFE_SetSelectEvent(self.__OnChangeMusic)
self.musicListDlg.Open()
def __ClickRadioButton(self, buttonList, buttonIndex):
try:
selButton=buttonList[buttonIndex]
except IndexError:
return
for eachButton in buttonList:
eachButton.SetUp()
selButton.Down()
def __SetTilingMode(self, index):
self.__ClickRadioButton(self.tilingModeButtonList, index)
self.tilingMode=index
def __SetCameraMode(self, index):
constInfo.SET_CAMERA_MAX_DISTANCE_INDEX(index)
self.__ClickRadioButton(self.cameraModeButtonList, index)
def __SetFogLevel(self, index):
# MR-14: Fog update by Alaric
# constInfo.SET_FOG_LEVEL_INDEX(index)
systemSetting.SetFogLevel(index)
# MR-14: -- END OF -- Fog update by Alaric
self.__ClickRadioButton(self.fogModeButtonList, index)
def __OnClickCameraModeShortButton(self):
self.__SetCameraMode(0)
def __OnClickCameraModeLongButton(self):
self.__SetCameraMode(1)
def __OnClickFogModeLevel0Button(self):
self.__SetFogLevel(0)
def __OnClickFogModeLevel1Button(self):
self.__SetFogLevel(1)
def __OnClickFogModeLevel2Button(self):
self.__SetFogLevel(2)
def __OnChangeMusic(self, fileName):
self.selectMusicFile.SetText(fileName[:MUSIC_FILENAME_MAX_LEN])
if musicInfo.fieldMusic != "":
snd.FadeOutMusic("BGM/" + musicInfo.fieldMusic)
if fileName==uiSelectMusic.DEFAULT_THEMA:
musicInfo.fieldMusic=musicInfo.METIN2THEMA
else:
musicInfo.fieldMusic=fileName
musicInfo.SaveLastPlayFieldMusic()
if musicInfo.fieldMusic != "":
snd.FadeInMusic("BGM/" + musicInfo.fieldMusic)
def OnChangeMusicVolume(self):
pos = self.ctrlMusicVolume.GetSliderPos()
snd.SetMusicVolume(pos)
systemSetting.SetMusicVolume(pos)
def OnChangeSoundVolume(self):
pos = self.ctrlSoundVolume.GetSliderPos()
snd.SetSoundVolume(pos)
systemSetting.SetSoundVolume(pos)
def OnChangeShadowQuality(self):
pos = self.ctrlShadowQuality.GetSliderPos()
systemSetting.SetShadowLevel(int(pos / 0.2))
def OnCloseInputDialog(self):
self.inputDialog.Close()
self.inputDialog = None
return True
def OnCloseQuestionDialog(self):
self.questionDialog.Close()
self.questionDialog = None
return True
def OnPressEscapeKey(self):
self.Close()
return True
def Show(self):
ui.ScriptWindow.Show(self)
def Close(self):
self.__SetCurTilingMode()
self.Hide()
def __SetCurTilingMode(self):
if background.IsSoftwareTiling():
self.__SetTilingMode(0)
else:
self.__SetTilingMode(1)
def __NotifyChatLine(self, text):
chat.AppendChat(chat.CHAT_TYPE_INFO, text)
-542
View File
@@ -1,542 +0,0 @@
import app
import ui
import player
import net
import wndMgr
import messenger
import guild
import chr
import nonplayer
import localeInfo
import constInfo
import uiCommon
class TargetBoard(ui.ThinBoard):
# Locale-independent button identifiers (never use translated strings as dict keys)
BTN_WHISPER = 0
BTN_EXCHANGE = 1
BTN_FIGHT = 2
BTN_ACCEPT_FIGHT = 3
BTN_AVENGE = 4
BTN_FRIEND = 5
BTN_INVITE_PARTY = 6
BTN_LEAVE_PARTY = 7
BTN_EXCLUDE = 8
BTN_INVITE_GUILD = 9
BTN_REMOVE_GUILD = 10
BTN_DISMOUNT = 11
BTN_EXIT_OBSERVER = 12
BTN_VIEW_EQUIPMENT = 13
BTN_REQUEST_ENTER_PARTY = 14
BTN_BUILDING_DESTROY = 15
BTN_EMOTION_ALLOW = 16
BTN_VOTE_BLOCK_CHAT = 17
# (buttonId, localeInfo attribute name) — text resolved at __init__ time
BUTTON_CONFIG = (
(BTN_WHISPER, "TARGET_BUTTON_WHISPER"),
(BTN_EXCHANGE, "TARGET_BUTTON_EXCHANGE"),
(BTN_FIGHT, "TARGET_BUTTON_FIGHT"),
(BTN_ACCEPT_FIGHT, "TARGET_BUTTON_ACCEPT_FIGHT"),
(BTN_AVENGE, "TARGET_BUTTON_AVENGE"),
(BTN_FRIEND, "TARGET_BUTTON_FRIEND"),
(BTN_INVITE_PARTY, "TARGET_BUTTON_INVITE_PARTY"),
(BTN_LEAVE_PARTY, "TARGET_BUTTON_LEAVE_PARTY"),
(BTN_EXCLUDE, "TARGET_BUTTON_EXCLUDE"),
(BTN_INVITE_GUILD, "TARGET_BUTTON_INVITE_GUILD"),
(BTN_REMOVE_GUILD, "TARGET_BUTTON_REMOVE_GUILD"),
(BTN_DISMOUNT, "TARGET_BUTTON_DISMOUNT"),
(BTN_EXIT_OBSERVER, "TARGET_BUTTON_EXIT_OBSERVER"),
(BTN_VIEW_EQUIPMENT, "TARGET_BUTTON_VIEW_EQUIPMENT"),
(BTN_REQUEST_ENTER_PARTY, "TARGET_BUTTON_REQUEST_ENTER_PARTY"),
(BTN_BUILDING_DESTROY, "TARGET_BUTTON_BUILDING_DESTROY"),
(BTN_EMOTION_ALLOW, "TARGET_BUTTON_EMOTION_ALLOW"),
(BTN_VOTE_BLOCK_CHAT, "VOTE_BLOCK_CHAT"),
)
GRADE_NAME = {}
EXCHANGE_LIMIT_RANGE = 3000
@staticmethod
def _RebuildLocaleStrings():
TargetBoard.GRADE_NAME = {
nonplayer.PAWN : localeInfo.TARGET_LEVEL_PAWN,
nonplayer.S_PAWN : localeInfo.TARGET_LEVEL_S_PAWN,
nonplayer.KNIGHT : localeInfo.TARGET_LEVEL_KNIGHT,
nonplayer.S_KNIGHT : localeInfo.TARGET_LEVEL_S_KNIGHT,
nonplayer.BOSS : localeInfo.TARGET_LEVEL_BOSS,
nonplayer.KING : localeInfo.TARGET_LEVEL_KING,
}
def __init__(self):
ui.ThinBoard.__init__(self)
name = ui.TextLine()
name.SetParent(self)
name.SetDefaultFontName()
name.SetOutline()
name.Show()
hpGauge = ui.Gauge()
hpGauge.SetParent(self)
hpGauge.MakeGauge(130, "red")
hpGauge.Hide()
closeButton = ui.Button()
closeButton.SetParent(self)
closeButton.SetUpVisual("d:/ymir work/ui/public/close_button_01.sub")
closeButton.SetOverVisual("d:/ymir work/ui/public/close_button_02.sub")
closeButton.SetDownVisual("d:/ymir work/ui/public/close_button_03.sub")
closeButton.SetPosition(30, 13)
if app.IsRTL():
hpGauge.SetPosition(55, 17)
hpGauge.SetWindowHorizontalAlignLeft()
closeButton.SetWindowHorizontalAlignLeft()
else:
hpGauge.SetPosition(175, 17)
hpGauge.SetWindowHorizontalAlignRight()
closeButton.SetWindowHorizontalAlignRight()
closeButton.SetEvent(ui.__mem_func__(self.OnPressedCloseButton))
closeButton.Show()
self.buttonDict = {}
self.showingButtonList = []
for btnId, localeAttr in self.BUTTON_CONFIG:
button = ui.Button()
button.SetParent(self)
if app.IsRTL():
button.SetUpVisual("d:/ymir work/ui/public/Small_Button_01.sub")
button.SetOverVisual("d:/ymir work/ui/public/Small_Button_02.sub")
button.SetDownVisual("d:/ymir work/ui/public/Small_Button_03.sub")
else:
button.SetUpVisual("d:/ymir work/ui/public/small_thin_button_01.sub")
button.SetOverVisual("d:/ymir work/ui/public/small_thin_button_02.sub")
button.SetDownVisual("d:/ymir work/ui/public/small_thin_button_03.sub")
button.SetWindowHorizontalAlignCenter()
button.SetText(getattr(localeInfo, localeAttr, localeAttr))
button.Hide()
self.buttonDict[btnId] = button
self.showingButtonList.append(button)
self.buttonDict[self.BTN_WHISPER].SetEvent(ui.__mem_func__(self.OnWhisper))
self.buttonDict[self.BTN_EXCHANGE].SetEvent(ui.__mem_func__(self.OnExchange))
self.buttonDict[self.BTN_FIGHT].SetEvent(ui.__mem_func__(self.OnPVP))
self.buttonDict[self.BTN_ACCEPT_FIGHT].SetEvent(ui.__mem_func__(self.OnPVP))
self.buttonDict[self.BTN_AVENGE].SetEvent(ui.__mem_func__(self.OnPVP))
self.buttonDict[self.BTN_FRIEND].SetEvent(ui.__mem_func__(self.OnAppendToMessenger))
self.buttonDict[self.BTN_INVITE_PARTY].SetEvent(ui.__mem_func__(self.OnPartyInvite))
self.buttonDict[self.BTN_LEAVE_PARTY].SetEvent(ui.__mem_func__(self.OnPartyExit))
self.buttonDict[self.BTN_EXCLUDE].SetEvent(ui.__mem_func__(self.OnPartyRemove))
self.buttonDict[self.BTN_INVITE_GUILD].SAFE_SetEvent(self.__OnGuildAddMember)
self.buttonDict[self.BTN_REMOVE_GUILD].SAFE_SetEvent(self.__OnGuildRemoveMember)
self.buttonDict[self.BTN_DISMOUNT].SAFE_SetEvent(self.__OnDismount)
self.buttonDict[self.BTN_EXIT_OBSERVER].SAFE_SetEvent(self.__OnExitObserver)
self.buttonDict[self.BTN_VIEW_EQUIPMENT].SAFE_SetEvent(self.__OnViewEquipment)
self.buttonDict[self.BTN_REQUEST_ENTER_PARTY].SAFE_SetEvent(self.__OnRequestParty)
self.buttonDict[self.BTN_BUILDING_DESTROY].SAFE_SetEvent(self.__OnDestroyBuilding)
self.buttonDict[self.BTN_EMOTION_ALLOW].SAFE_SetEvent(self.__OnEmotionAllow)
self.buttonDict[self.BTN_VOTE_BLOCK_CHAT].SetEvent(ui.__mem_func__(self.__OnVoteBlockChat))
self.name = name
self.hpGauge = hpGauge
self.closeButton = closeButton
self.nameString = 0
self.nameLength = 0
self.vid = 0
self.eventWhisper = None
self.isShowButton = False
self.__Initialize()
self.ResetTargetBoard()
def __del__(self):
ui.ThinBoard.__del__(self)
print("===================================================== DESTROYED TARGET BOARD")
def __Initialize(self):
self.nameString = ""
self.nameLength = 0
self.vid = 0
self.isShowButton = False
def Destroy(self):
self.eventWhisper = None
self.closeButton = None
self.showingButtonList = None
self.buttonDict = None
self.name = None
self.hpGauge = None
self.__Initialize()
def OnPressedCloseButton(self):
player.ClearTarget()
self.Close()
def Close(self):
self.__Initialize()
self.Hide()
def Open(self, vid, name):
if vid:
if not constInfo.GET_VIEW_OTHER_EMPIRE_PLAYER_TARGET_BOARD():
if not player.IsSameEmpire(vid):
self.Hide()
return
if vid != self.GetTargetVID():
self.ResetTargetBoard()
self.SetTargetVID(vid)
self.SetTargetName(name)
if player.IsMainCharacterIndex(vid):
self.__ShowMainCharacterMenu()
elif chr.INSTANCE_TYPE_BUILDING == chr.GetInstanceType(self.vid):
self.Hide()
else:
self.RefreshButton()
self.Show()
else:
self.HideAllButton()
self.__ShowButton(self.BTN_WHISPER)
self.__ShowButton(self.BTN_VOTE_BLOCK_CHAT)
self.__ArrangeButtonPosition()
self.SetTargetName(name)
self.Show()
def Refresh(self):
if self.IsShow():
if self.IsShowButton():
self.RefreshButton()
def RefreshByVID(self, vid):
if vid == self.GetTargetVID():
self.Refresh()
def RefreshByName(self, name):
if name == self.GetTargetName():
self.Refresh()
def __ShowMainCharacterMenu(self):
canShow=0
self.HideAllButton()
if player.IsMountingHorse():
self.__ShowButton(self.BTN_DISMOUNT)
canShow=1
if player.IsObserverMode():
self.__ShowButton(self.BTN_EXIT_OBSERVER)
canShow=1
if canShow:
self.__ArrangeButtonPosition()
self.Show()
else:
self.Hide()
def __ShowNameOnlyMenu(self):
self.HideAllButton()
def SetWhisperEvent(self, event):
self.eventWhisper = event
def UpdatePosition(self):
self.SetPosition(wndMgr.GetScreenWidth() // 2 - self.GetWidth() // 2, 10)
def ResetTargetBoard(self):
for btn in list(self.buttonDict.values()):
btn.Hide()
self.__Initialize()
self.name.SetPosition(0, 13)
self.name.SetHorizontalAlignCenter()
self.name.SetWindowHorizontalAlignCenter()
self.hpGauge.Hide()
self.SetSize(250, 40)
def SetTargetVID(self, vid):
self.vid = vid
def SetEnemyVID(self, vid):
self.SetTargetVID(vid)
name = chr.GetNameByVID(vid)
level = nonplayer.GetLevelByVID(vid)
grade = nonplayer.GetGradeByVID(vid)
nameFront = ""
if -1 != level:
nameFront += "Lv." + str(level) + " "
if grade in self.GRADE_NAME:
nameFront += "(" + self.GRADE_NAME[grade] + ") "
self.SetTargetName(nameFront + name)
def GetTargetVID(self):
return self.vid
def GetTargetName(self):
return self.nameString
def SetTargetName(self, name):
self.nameString = name
self.nameLength = len(name)
self.name.SetText(name)
def SetHP(self, hpPercentage):
if not self.hpGauge.IsShow():
self.SetSize(200 + 7 * self.nameLength, self.GetHeight())
if app.IsRTL():
self.name.SetPosition( self.GetWidth()-23, 13)
else:
self.name.SetPosition(23, 13)
self.name.SetWindowHorizontalAlignLeft()
self.name.SetHorizontalAlignLeft()
self.hpGauge.Show()
self.UpdatePosition()
self.hpGauge.SetPercentage(hpPercentage, 100)
def ShowDefaultButton(self):
self.isShowButton = True
self.showingButtonList.append(self.buttonDict[self.BTN_WHISPER])
self.showingButtonList.append(self.buttonDict[self.BTN_EXCHANGE])
self.showingButtonList.append(self.buttonDict[self.BTN_FIGHT])
self.showingButtonList.append(self.buttonDict[self.BTN_EMOTION_ALLOW])
for button in self.showingButtonList:
button.Show()
def HideAllButton(self):
self.isShowButton = False
for button in self.showingButtonList:
button.Hide()
self.showingButtonList = []
def __ShowButton(self, name):
if name not in self.buttonDict:
return
self.buttonDict[name].Show()
self.showingButtonList.append(self.buttonDict[name])
def __HideButton(self, name):
if name not in self.buttonDict:
return
button = self.buttonDict[name]
button.Hide()
for btnInList in self.showingButtonList:
if btnInList == button:
self.showingButtonList.remove(button)
break
def OnWhisper(self):
if None != self.eventWhisper:
self.eventWhisper(self.nameString)
def OnExchange(self):
net.SendExchangeStartPacket(self.vid)
def OnPVP(self):
net.SendChatPacket("/pvp %d" % (self.vid))
def OnAppendToMessenger(self):
net.SendMessengerAddByVIDPacket(self.vid)
def OnPartyInvite(self):
net.SendPartyInvitePacket(self.vid)
def OnPartyExit(self):
net.SendPartyExitPacket()
def OnPartyRemove(self):
net.SendPartyRemovePacket(self.vid)
def __OnGuildAddMember(self):
net.SendGuildAddMemberPacket(self.vid)
def __OnGuildRemoveMember(self):
self.questionDialog = uiCommon.QuestionDialog()
self.questionDialog.SetText(localeInfo.GUILD_REMOVE_MEMBER_QUESTION)
self.questionDialog.SetAcceptEvent(ui.__mem_func__(self.__OnGuildRemoveMemberAccept))
self.questionDialog.SetCancelEvent(ui.__mem_func__(self.__OnGuildRemoveMemberClose))
self.questionDialog.Open()
def __OnGuildRemoveMemberAccept(self):
net.SendGuildRemoveMemberPacket(self.nameString)
self.__OnGuildRemoveMemberClose()
def __OnGuildRemoveMemberClose(self):
self.questionDialog.Close()
self.questionDialog = None
return True
def __OnDismount(self):
net.SendChatPacket("/unmount")
def __OnExitObserver(self):
net.SendChatPacket("/observer_exit")
def __OnViewEquipment(self):
net.SendChatPacket("/view_equip " + str(self.vid))
def __OnRequestParty(self):
net.SendChatPacket("/party_request " + str(self.vid))
def __OnDestroyBuilding(self):
net.SendChatPacket("/build d %d" % (self.vid))
def __OnEmotionAllow(self):
net.SendChatPacket("/emotion_allow %d" % (self.vid))
def __OnVoteBlockChat(self):
cmd = "/vote_block_chat %s" % (self.nameString)
net.SendChatPacket(cmd)
def OnPressEscapeKey(self):
self.OnPressedCloseButton()
return True
def IsShowButton(self):
return self.isShowButton
def RefreshButton(self):
self.HideAllButton()
if chr.INSTANCE_TYPE_BUILDING == chr.GetInstanceType(self.vid):
#self.__ShowButton(self.BTN_BUILDING_DESTROY)
#self.__ArrangeButtonPosition()
return
if player.IsPVPInstance(self.vid) or player.IsObserverMode():
# PVP_INFO_SIZE_BUG_FIX
self.SetSize(200 + 7 * self.nameLength, 40)
self.UpdatePosition()
# END_OF_PVP_INFO_SIZE_BUG_FIX
return
self.ShowDefaultButton()
def isGuildMaster(name):
guildMasterName = guild.GetGuildMasterName()
return guildMasterName == name
def isGuildMember(name, vid):
return guild.IsMemberByName(name) and chr.GetGuildID(vid) != 0
def isNotGuildMember(name, vid):
return not guild.IsMemberByName(name) and chr.GetGuildID(vid) == 0
guildAuthorityButtons = {
guild.AUTH_ADD_MEMBER: {
"btn": self.BTN_INVITE_GUILD,
"condition": lambda: isNotGuildMember(self.nameString, self.vid),
},
guild.AUTH_REMOVE_MEMBER: {
"btn": self.BTN_REMOVE_GUILD,
"condition": lambda: isGuildMember(self.nameString, self.vid) and not isGuildMaster(self.nameString),
},
}
for guildAuthority, guildButton in guildAuthorityButtons.items():
hasAuthority = guild.MainPlayerHasAuthority(guildAuthority)
satisfiesCondition = guildButton["condition"]()
if hasAuthority and satisfiesCondition:
self.__ShowButton(guildButton["btn"])
if not messenger.IsFriendByName(self.nameString):
self.__ShowButton(self.BTN_FRIEND)
if player.IsPartyMember(self.vid):
self.__HideButton(self.BTN_FIGHT)
if player.IsPartyLeader(self.vid):
self.__ShowButton(self.BTN_LEAVE_PARTY)
elif player.IsPartyLeader(player.GetMainCharacterIndex()):
self.__ShowButton(self.BTN_EXCLUDE)
else:
if player.IsPartyMember(player.GetMainCharacterIndex()):
if player.IsPartyLeader(player.GetMainCharacterIndex()):
self.__ShowButton(self.BTN_INVITE_PARTY)
else:
if chr.IsPartyMember(self.vid):
self.__ShowButton(self.BTN_REQUEST_ENTER_PARTY)
else:
self.__ShowButton(self.BTN_INVITE_PARTY)
if player.IsRevengeInstance(self.vid):
self.__HideButton(self.BTN_FIGHT)
self.__ShowButton(self.BTN_AVENGE)
elif player.IsChallengeInstance(self.vid):
self.__HideButton(self.BTN_FIGHT)
self.__ShowButton(self.BTN_ACCEPT_FIGHT)
elif player.IsCantFightInstance(self.vid):
self.__HideButton(self.BTN_FIGHT)
if not player.IsSameEmpire(self.vid):
self.__HideButton(self.BTN_INVITE_PARTY)
self.__HideButton(self.BTN_FRIEND)
self.__HideButton(self.BTN_FIGHT)
distance = player.GetCharacterDistance(self.vid)
if distance > self.EXCHANGE_LIMIT_RANGE:
self.__HideButton(self.BTN_EXCHANGE)
self.__ArrangeButtonPosition()
self.__ArrangeButtonPosition()
def __ArrangeButtonPosition(self):
showingButtonCount = len(self.showingButtonList)
pos = -(showingButtonCount // 2) * 68
if 0 == showingButtonCount % 2:
pos += 34
for button in self.showingButtonList:
button.SetPosition(pos, 33)
pos += 68
self.SetSize(max(150, showingButtonCount * 75), 65)
self.UpdatePosition()
def OnUpdate(self):
if self.isShowButton:
exchangeButton = self.buttonDict[self.BTN_EXCHANGE]
distance = player.GetCharacterDistance(self.vid)
if distance < 0:
return
if exchangeButton.IsShow():
if distance > self.EXCHANGE_LIMIT_RANGE:
self.RefreshButton()
else:
if distance < self.EXCHANGE_LIMIT_RANGE:
self.RefreshButton()
TargetBoard._RebuildLocaleStrings()
localeInfo.RegisterReloadCallback(TargetBoard._RebuildLocaleStrings)
File diff suppressed because it is too large Load Diff
-327
View File
@@ -1,327 +0,0 @@
import ui
import grp
import app
import wndMgr
class TextBar(ui.Window):
def __init__(self, width, height):
ui.Window.__init__(self)
self.handle = grp.CreateTextBar(width, height)
def __del__(self):
ui.Window.__del__(self)
grp.DestroyTextBar(self.handle)
def ClearBar(self):
grp.ClearTextBar(self.handle)
def SetClipRect(self, x1, y1, x2, y2):
grp.SetTextBarClipRect(self.handle, x1, y1, x2, y2)
def TextOut(self, x, y, text):
grp.TextBarTextOut(self.handle, x, y, text)
def OnRender(self):
x, y = self.GetGlobalPosition()
grp.RenderTextBar(self.handle, x, y)
def SetTextColor(self, r, g, b):
grp.TextBarSetTextColor(self.handle, r, g, b)
def GetTextExtent(self, text):
return grp.TextBarGetTextExtent(self.handle, text)
class TipBoard(ui.Bar):
SCROLL_WAIT_TIME = 3.0
TIP_DURATION = 5.0
STEP_HEIGHT = 17
def __init__(self):
ui.Bar.__init__(self)
self.AddFlag("not_pick")
self.tipList = []
self.curPos = 0
self.dstPos = 0
self.nextScrollTime = 0
self.width = 370
self.SetPosition(0, 70)
self.SetSize(370, 20)
self.SetColor(grp.GenerateColor(0.0, 0.0, 0.0, 0.5))
self.SetWindowHorizontalAlignCenter()
self.__CreateTextBar()
def __del__(self):
ui.Bar.__del__(self)
def __CreateTextBar(self):
x, y = self.GetGlobalPosition()
self.textBar = TextBar(370, 300)
self.textBar.SetParent(self)
self.textBar.SetPosition(3, 5)
self.textBar.SetClipRect(0, y, wndMgr.GetScreenWidth(), y+18)
self.textBar.Show()
def __CleanOldTip(self):
leaveList = []
for tip in self.tipList:
madeTime = tip[0]
if app.GetTime() - madeTime > self.TIP_DURATION:
pass
else:
leaveList.append(tip)
self.tipList = leaveList
if not leaveList:
self.textBar.ClearBar()
self.Hide()
return
self.__RefreshBoard()
def __RefreshBoard(self):
self.textBar.ClearBar()
index = 0
for tip in self.tipList:
text = tip[1]
self.textBar.TextOut(0, index*self.STEP_HEIGHT, text)
index += 1
def SetTip(self, text):
if not app.IsVisibleNotice():
return
curTime = app.GetTime()
self.tipList.append((curTime, text))
self.__RefreshBoard()
self.nextScrollTime = app.GetTime() + 1.0
if not self.IsShow():
self.curPos = -self.STEP_HEIGHT
self.dstPos = -self.STEP_HEIGHT
self.textBar.SetPosition(3, 5 - self.curPos)
self.Show()
def OnUpdate(self):
if not self.tipList:
self.Hide()
return
if app.GetTime() > self.nextScrollTime:
self.nextScrollTime = app.GetTime() + self.SCROLL_WAIT_TIME
self.dstPos = self.curPos + self.STEP_HEIGHT
if self.dstPos > self.curPos:
self.curPos += 1
self.textBar.SetPosition(3, 5 - self.curPos)
if self.curPos > len(self.tipList)*self.STEP_HEIGHT:
self.curPos = -self.STEP_HEIGHT
self.dstPos = -self.STEP_HEIGHT
self.__CleanOldTip()
class BigTextBar(TextBar):
def __init__(self, width, height, fontSize):
ui.Window.__init__(self)
self.handle = grp.CreateBigTextBar(width, height, fontSize)
class BigBoard(ui.Bar):
SCROLL_WAIT_TIME = 5.0
TIP_DURATION = 10.0
FONT_WIDTH = 18
FONT_HEIGHT = 18
LINE_WIDTH = 500
LINE_HEIGHT = FONT_HEIGHT + 5
STEP_HEIGHT = LINE_HEIGHT * 2
LINE_CHANGE_LIMIT_WIDTH = 350
FRAME_IMAGE_FILE_NAME_LIST = [
"season1/interface/oxevent/frame_0.sub",
"season1/interface/oxevent/frame_1.sub",
"season1/interface/oxevent/frame_2.sub",
]
FRAME_IMAGE_STEP = 256
FRAME_BASE_X = -20
FRAME_BASE_Y = -12
def __init__(self):
ui.Bar.__init__(self)
self.AddFlag("not_pick")
self.tipList = []
self.curPos = 0
self.dstPos = 0
self.nextScrollTime = 0
self.SetPosition(0, 150)
self.SetSize(512, 55)
self.SetColor(grp.GenerateColor(0.0, 0.0, 0.0, 0.5))
self.SetWindowHorizontalAlignCenter()
self.__CreateTextBar()
self.__LoadFrameImages()
def __LoadFrameImages(self):
x = self.FRAME_BASE_X
y = self.FRAME_BASE_Y
self.imgList = []
for imgFileName in self.FRAME_IMAGE_FILE_NAME_LIST:
self.imgList.append(self.__LoadImage(x, y, imgFileName))
x += self.FRAME_IMAGE_STEP
def __LoadImage(self, x, y, fileName):
img = ui.ImageBox()
img.SetParent(self)
img.AddFlag("not_pick")
img.LoadImage(fileName)
img.SetPosition(x, y)
img.Show()
return img
def __del__(self):
ui.Bar.__del__(self)
def __CreateTextBar(self):
x, y = self.GetGlobalPosition()
self.textBar = BigTextBar(self.LINE_WIDTH, 300, self.FONT_HEIGHT)
self.textBar.SetParent(self)
self.textBar.SetPosition(6, 8)
self.textBar.SetTextColor(242, 231, 193)
self.textBar.SetClipRect(0, y+8, wndMgr.GetScreenWidth(), y+8+self.STEP_HEIGHT)
self.textBar.Show()
def __CleanOldTip(self):
curTime = app.GetTime()
leaveList = []
for madeTime, text in self.tipList:
if curTime + self.TIP_DURATION <= madeTime:
leaveList.append(text)
self.tipList = leaveList
if not leaveList:
self.textBar.ClearBar()
self.Hide()
return
self.__RefreshBoard()
def __RefreshBoard(self):
self.textBar.ClearBar()
if len(self.tipList) == 1:
checkTime, text = self.tipList[0]
(text_width, text_height) = self.textBar.GetTextExtent(text)
self.textBar.TextOut((500-text_width)//2, (self.STEP_HEIGHT-8-text_height)//2, text)
else:
index = 0
for checkTime, text in self.tipList:
(text_width, text_height) = self.textBar.GetTextExtent(text)
self.textBar.TextOut((500-text_width)//2, index*self.LINE_HEIGHT, text)
index += 1
def SetTip(self, text):
if not app.IsVisibleNotice():
return
curTime = app.GetTime()
self.__AppendText(curTime, text)
self.__RefreshBoard()
self.nextScrollTime = curTime + 1.0
if not self.IsShow():
self.curPos = -self.STEP_HEIGHT
self.dstPos = -self.STEP_HEIGHT
self.textBar.SetPosition(3, 8 - self.curPos)
self.Show()
def __AppendText(self, curTime, text):
import dbg
prevPos = 0
while 1:
curPos = text.find(" ", prevPos)
if curPos < 0:
break
(text_width, text_height) = self.textBar.GetTextExtent(text[:curPos])
if text_width > self.LINE_CHANGE_LIMIT_WIDTH:
self.tipList.append((curTime, text[:prevPos]))
self.tipList.append((curTime, text[prevPos:]))
return
prevPos = curPos + 1
self.tipList.append((curTime, text))
def OnUpdate(self):
if not self.tipList:
self.Hide()
return
if app.GetTime() > self.nextScrollTime:
self.nextScrollTime = app.GetTime() + self.SCROLL_WAIT_TIME
self.dstPos = self.curPos + self.STEP_HEIGHT
if self.dstPos > self.curPos:
self.curPos += 1
self.textBar.SetPosition(3, 8 - self.curPos)
if self.curPos > len(self.tipList)*self.LINE_HEIGHT:
self.curPos = -self.STEP_HEIGHT
self.dstPos = -self.STEP_HEIGHT
self.__CleanOldTip()
if __name__ == "__main__":
import app
import wndMgr
import systemSetting
import mouseModule
import grp
import ui
#wndMgr.SetOutlineFlag(True)
app.SetMouseHandler(mouseModule.mouseController)
app.SetHairColorEnable(True)
wndMgr.SetMouseHandler(mouseModule.mouseController)
wndMgr.SetScreenSize(systemSetting.GetWidth(), systemSetting.GetHeight())
app.Create("METIN2 CLOSED BETA", systemSetting.GetWidth(), systemSetting.GetHeight(), 1)
mouseModule.mouseController.Create()
wnd = BigBoard()
wnd.Show()
wnd.SetTip("안녕하세요")
wnd.SetTip("저는 빗자루 입니다")
app.Loop()
File diff suppressed because it is too large Load Diff
-392
View File
@@ -1,392 +0,0 @@
import app
import ui
import localeInfo
import uiScriptLocale
class MarkItem(ui.ListBoxEx.Item):
def __init__(self, fileName):
ui.ListBoxEx.Item.__init__(self)
self.fileName = fileName
self.fullPath = "upload/" + fileName
self.imgWidth = 0
self.imgHeight = 0
self.canLoad = 0
self.imgBox = None
self.imageLoaded = False
self.textLine = self.__CreateTextLine(fileName)
def __del__(self):
ui.ListBoxEx.Item.__del__(self)
def GetText(self):
return self.textLine.GetText()
def SetSize(self, width, height):
ui.ListBoxEx.Item.SetSize(self, 20 + 6*len(self.textLine.GetText()) + 4, height)
def __CreateTextLine(self, fileName):
textLine = ui.TextLine()
textLine.SetParent(self)
textLine.SetPosition(20, 0)
textLine.SetText(fileName)
textLine.Show()
return textLine
def LoadImageInfo(self):
"""Load image info lazily when needed (e.g., when selected or validated)"""
if self.imageLoaded:
return
self.imageLoaded = True
(self.canLoad, self.imgWidth, self.imgHeight) = app.GetImageInfo(self.fullPath)
if self.canLoad == 1 and self.imgWidth == 16 and self.imgHeight == 12:
imgBox = ui.ImageBox()
imgBox.AddFlag("not_pick")
imgBox.SetParent(self)
imgBox.SetPosition(0, 2)
imgBox.LoadImageFromFile(self.fullPath)
imgBox.Show()
self.imgBox = imgBox
def OnRender(self):
# Load image when item becomes visible (rendered)
if not self.imageLoaded:
self.LoadImageInfo()
# Call parent to draw selection bar
ui.ListBoxEx.Item.OnRender(self)
class SymbolItem(ui.ListBoxEx.Item):
def __init__(self, fileName):
ui.ListBoxEx.Item.__init__(self)
self.fileName = fileName
self.fullPath = "upload/" + fileName
self.imgWidth = 0
self.imgHeight = 0
self.canLoad = 0
self.imageLoaded = False
self.textLine = self.__CreateTextLine(fileName)
def __del__(self):
ui.ListBoxEx.Item.__del__(self)
def GetText(self):
return self.textLine.GetText()
def SetSize(self, width, height):
ui.ListBoxEx.Item.SetSize(self, 6*len(self.textLine.GetText()) + 4, height)
def __CreateTextLine(self, fileName):
textLine = ui.TextLine()
textLine.SetParent(self)
textLine.SetPosition(1, 2)
textLine.SetText(fileName)
textLine.Show()
return textLine
def LoadImageInfo(self):
"""Load image info lazily when needed"""
if self.imageLoaded:
return
self.imageLoaded = True
(self.canLoad, self.imgWidth, self.imgHeight) = app.GetImageInfo(self.fullPath)
def OnRender(self):
# Load image when item becomes visible (rendered)
if not self.imageLoaded:
self.LoadImageInfo()
# Call parent to draw selection bar
ui.ListBoxEx.Item.OnRender(self)
class PopupDialog(ui.ScriptWindow):
def __init__(self, parent):
print("NEW POPUP WINDOW ----------------------------------------------------------------------------")
ui.ScriptWindow.__init__(self)
self.__Load()
self.__Bind()
def __del__(self):
ui.ScriptWindow.__del__(self)
print("---------------------------------------------------------------------------- DELETE POPUP WINDOW")
def __Load(self):
try:
pyScrLoader = ui.PythonScriptLoader()
pyScrLoader.LoadScriptFile(self, "UIScript/PopupDialog.py")
except:
import exception
exception.Abort("PopupDialog.__Load")
def __Bind(self):
try:
self.textLine=self.GetChild("message")
self.okButton=self.GetChild("accept")
except:
import exception
exception.Abort("PopupDialog.__Bind")
self.okButton.SetEvent(ui.__mem_func__(self.__OnOK))
def Open(self, msg):
self.textLine.SetText(msg)
self.SetCenterPosition()
self.Show()
self.SetTop()
def __OnOK(self):
self.Hide()
class MarkSelectDialog(ui.ScriptWindow):
def __init__(self):
print("NEW MARK LIST WINDOW ----------------------------------------------------------------------------")
ui.ScriptWindow.__init__(self)
self.selectEvent=None
self.isLoaded=0
def __del__(self):
ui.ScriptWindow.__del__(self)
print("---------------------------------------------------------------------------- DELETE MARK LIST WINDOW")
def Show(self):
if self.isLoaded==0:
self.isLoaded=1
self.__Load()
ui.ScriptWindow.Show(self)
def Open(self):
self.Show()
self.SetCenterPosition()
self.SetTop()
if self.markListBox.IsEmpty():
self.__PopupMessage(localeInfo.GUILDMARK_UPLOADER_ERROR_PATH)
def Close(self):
self.popupDialog.Hide()
self.Hide()
def OnPressEscapeKey(self):
self.Close()
return True
def SAFE_SetSelectEvent(self, event):
self.selectEvent=ui.__mem_func__(event)
def __CreateMarkListBox(self):
markListBox=ui.ListBoxEx()
markListBox.SetParent(self)
markListBox.SetPosition(15, 50)
markListBox.Show()
return markListBox
def __Load(self):
self.popupDialog=PopupDialog(self)
try:
pyScrLoader = ui.PythonScriptLoader()
pyScrLoader.LoadScriptFile(self, "UIScript/MarkListWindow.py")
except:
import exception
exception.Abort("MarkListBox.__Load")
try:
self.markListBox=self.__CreateMarkListBox()
self.markListBox.SetScrollBar(self.GetChild("ScrollBar"))
self.popupText = self.popupDialog.GetChild("message")
self.popupDialog.GetChild("accept").SetEvent(ui.__mem_func__(self.popupDialog.Hide))
self.board=self.GetChild("board")
self.okButton=self.GetChild("ok")
self.cancelButton=self.GetChild("cancel")
self.refreshButton=self.GetChild("refresh")
except:
import exception
exception.Abort("MarkListBox.__Bind")
self.refreshButton.SetEvent(ui.__mem_func__(self.__OnRefresh))
self.cancelButton.SetEvent(ui.__mem_func__(self.__OnCancel))
self.okButton.SetEvent(ui.__mem_func__(self.__OnOK))
self.board.SetCloseEvent(ui.__mem_func__(self.__OnCancel))
self.UpdateRect()
self.__RefreshFileList()
def __PopupMessage(self, msg):
self.popupDialog.Open(msg)
def __OnOK(self):
selItem = self.markListBox.GetSelectedItem()
if selItem:
# Ensure image info is loaded before validation
selItem.LoadImageInfo()
if selItem.canLoad != 1:
self.__PopupMessage(localeInfo.GUILDMARK_UPLOADER_ERROR_FILE_FORMAT)
elif selItem.imgWidth != 16:
self.__PopupMessage(localeInfo.GUILDMARK_UPLOADER_ERROR_16_WIDTH)
elif selItem.imgHeight != 12:
self.__PopupMessage(localeInfo.GUILDMARK_UPLOADER_ERROR_12_HEIGHT)
else:
self.selectEvent(selItem.GetText())
self.Hide()
else:
self.__PopupMessage(localeInfo.GUILDMARK_UPLOADER_ERROR_SELECT)
def __OnCancel(self):
self.Hide()
def __OnRefresh(self):
self.__RefreshFileList()
def __RefreshFileList(self):
self.__ClearFileList()
# Collect all files first, then batch add to avoid multiple UI updates
allFiles = []
for ext in ("bmp", "tga", "jpg", "jpeg", "png"):
fileNameList = app.GetFileList("upload/*." + ext)
allFiles.extend(fileNameList)
# Sort alphabetically for consistent display
allFiles.sort()
# Add all files at once
for fileName in allFiles:
self.__AppendFile(fileName)
def __ClearFileList(self):
self.markListBox.RemoveAllItems()
def __AppendFile(self, fileName):
self.markListBox.AppendItem(MarkItem(fileName))
class SymbolSelectDialog(ui.ScriptWindow):
def __init__(self):
print("NEW SYMBOL LIST WINDOW ----------------------------------------------------------------------------")
ui.ScriptWindow.__init__(self)
self.selectEvent=None
self.isLoaded=0
def __del__(self):
ui.ScriptWindow.__del__(self)
print("---------------------------------------------------------------------------- DELETE SYMBOL LIST WINDOW")
def Show(self):
if self.isLoaded==0:
self.isLoaded=1
self.__Load()
ui.ScriptWindow.Show(self)
def Open(self):
self.Show()
self.SetCenterPosition()
self.SetTop()
if self.symbolListBox.IsEmpty():
self.__PopupMessage(localeInfo.GUILDMARK_UPLOADER_ERROR_PATH)
def Close(self):
self.popupDialog.Hide()
self.Hide()
def OnPressEscapeKey(self):
self.Close()
return True
def SAFE_SetSelectEvent(self, event):
self.selectEvent=ui.__mem_func__(event)
def __CreateSymbolListBox(self):
symbolListBox=ui.ListBoxEx()
symbolListBox.SetParent(self)
symbolListBox.SetPosition(15, 50)
symbolListBox.Show()
return symbolListBox
def __Load(self):
self.popupDialog=PopupDialog(self)
try:
pyScrLoader = ui.PythonScriptLoader()
pyScrLoader.LoadScriptFile(self, "UIScript/MarkListWindow.py")
except:
import exception
exception.Abort("SymbolListBox.__Load")
try:
self.symbolListBox=self.__CreateSymbolListBox()
self.symbolListBox.SetScrollBar(self.GetChild("ScrollBar"))
self.popupText = self.popupDialog.GetChild("message")
self.popupDialog.GetChild("accept").SetEvent(ui.__mem_func__(self.popupDialog.Hide))
self.board=self.GetChild("board")
self.okButton=self.GetChild("ok")
self.cancelButton=self.GetChild("cancel")
self.refreshButton=self.GetChild("refresh")
except:
import exception
exception.Abort("SymbolListBox.__Bind")
self.refreshButton.SetEvent(ui.__mem_func__(self.__OnRefresh))
self.cancelButton.SetEvent(ui.__mem_func__(self.__OnCancel))
self.okButton.SetEvent(ui.__mem_func__(self.__OnOK))
self.board.SetCloseEvent(ui.__mem_func__(self.__OnCancel))
self.board.SetTitleName(localeInfo.SYMBOLLIST_TITLE)
self.UpdateRect()
self.__RefreshFileList()
def __PopupMessage(self, msg):
self.popupDialog.Open(msg)
def __OnOK(self):
selItem = self.symbolListBox.GetSelectedItem()
if selItem:
# Ensure image info is loaded before validation
selItem.LoadImageInfo()
if selItem.canLoad != 1:
self.__PopupMessage(localeInfo.GUILDMARK_UPLOADER_ERROR_FILE_FORMAT)
elif selItem.imgWidth != 64:
self.__PopupMessage(localeInfo.GUILDMARK_UPLOADER_ERROR_64_WIDTH)
elif selItem.imgHeight != 128:
self.__PopupMessage(localeInfo.GUILDMARK_UPLOADER_ERROR_128_HEIGHT)
else:
self.selectEvent(selItem.GetText())
self.Hide()
else:
self.__PopupMessage(localeInfo.GUILDMARK_UPLOADER_ERROR_SELECT)
def __OnCancel(self):
self.Hide()
def __OnRefresh(self):
self.__RefreshFileList()
def __RefreshFileList(self):
self.__ClearFileList()
self.__AppendFileList("jpg")
def __ClearFileList(self):
self.symbolListBox.RemoveAllItems()
def __AppendFileList(self, filter):
fileNameList=app.GetFileList("upload/*."+filter)
for fileName in fileNameList:
self.__AppendFile(fileName)
def __AppendFile(self, fileName):
self.symbolListBox.AppendItem(SymbolItem(fileName))
-127
View File
@@ -1,127 +0,0 @@
import ui
import uiScriptLocale
import net
import snd
import app
import mouseModule
import constInfo
class WebWindow(ui.ScriptWindow):
def __init__(self):
ui.ScriptWindow.__init__(self, "TOP_MOST")
self.oldPos = None
def __del__(self):
ui.ScriptWindow.__del__(self)
def LoadWindow(self):
try:
pyScrLoader = ui.PythonScriptLoader()
pyScrLoader.LoadScriptFile(self, "UIScript/WebWindow.py")
except:
import exception
exception.Abort("WebWindow.LoadDialog.LoadScript")
try:
GetObject=self.GetChild
self.titleBar = GetObject("TitleBar")
except:
import exception
exception.Abort("WebWindow.LoadDialog.BindObject")
self.titleBar.SetCloseEvent(ui.__mem_func__(self.__OnCloseButtonClick))
def Destroy(self):
app.HideWebPage()
self.ClearDictionary()
self.titleBar = None
def Open(self, url):
self.Refresh()
self.Show()
self.SetCenterPosition()
x, y = self.GetGlobalPosition()
sx, sy = x + 10, y + 30
ex, ey = sx + self.GetWidth() - 20, sy + self.GetHeight() - 40
app.ShowWebPage(url, (sx, sy, ex, ey))
def Close(self):
app.HideWebPage()
self.Hide()
def Clear(self):
self.Refresh()
def Refresh(self):
pass
def __OnCloseButtonClick(self):
print("close_web:click_close_button")
self.Close()
def OnPressEscapeKey(self):
print("close_web:esc_key")
self.Close()
return True
def OnUpdate(self):
newPos = self.GetGlobalPosition()
if newPos == self.oldPos:
return
self.oldPos = newPos
x, y = newPos
sx, sy = x + 10, y + 30
ex, ey = sx + self.GetWidth() - 20, sy + self.GetHeight() - 40
app.MoveWebPage((sx, sy, ex, ey))
if __name__ == "__main__":
import app
import wndMgr
import systemSetting
import mouseModule
import grp
import ui
import uiToolTip
import localeInfo
app.SetMouseHandler(mouseModule.mouseController)
app.SetHairColorEnable(True)
wndMgr.SetMouseHandler(mouseModule.mouseController)
wndMgr.SetScreenSize(systemSetting.GetWidth(), systemSetting.GetHeight())
app.Create("METIN2", systemSetting.GetWidth(), systemSetting.GetHeight(), 1)
mouseModule.mouseController.Create()
class TestGame(ui.Window):
def __init__(self):
ui.Window.__init__(self)
localeInfo.LoadLocaleData()
self.mallWindow = WebWindow()
self.mallWindow.LoadWindow()
self.mallWindow.Open()
def __del__(self):
ui.Window.__del__(self)
def OnUpdate(self):
app.UpdateGame()
def OnRender(self):
app.RenderGame()
grp.PopState()
grp.SetInterfaceRenderState()
game = TestGame()
game.SetSize(systemSetting.GetWidth(), systemSetting.GetHeight())
game.Show()
app.Loop()
-330
View File
@@ -1,330 +0,0 @@
import ui
import net
import chat
import player
import app
import localeInfo
import ime
import chr
class WhisperButton(ui.Button):
def __init__(self):
ui.Button.__init__(self, "TOP_MOST")
def __del__(self):
ui.Button.__del__(self)
def SetToolTipText(self, text, x=0, y = 32):
ui.Button.SetToolTipText(self, text, x, y)
self.ToolTipText.Show()
def SetToolTipTextWithColor(self, text, color, x=0, y = 32):
ui.Button.SetToolTipText(self, text, x, y)
self.ToolTipText.SetPackedFontColor(color)
self.ToolTipText.Show()
def ShowToolTip(self):
if 0 != self.ToolTipText:
self.ToolTipText.Show()
def HideToolTip(self):
if 0 != self.ToolTipText:
self.ToolTipText.Show()
class WhisperDialog(ui.ScriptWindow):
class TextRenderer(ui.Window):
def SetTargetName(self, targetName):
self.targetName = targetName
def OnRender(self):
(x, y) = self.GetGlobalPosition()
chat.RenderWhisper(self.targetName, x, y)
class ResizeButton(ui.DragButton):
def __init__(self):
ui.DragButton.__init__(self)
def __del__(self):
ui.DragButton.__del__(self)
def OnMouseOverIn(self):
app.SetCursor(app.HVSIZE)
def OnMouseOverOut(self):
app.SetCursor(app.NORMAL)
def __init__(self, eventMinimize, eventClose):
print("NEW WHISPER DIALOG ----------------------------------------------------------------------------")
ui.ScriptWindow.__init__(self)
self.targetName = ""
self.eventMinimize = eventMinimize
self.eventClose = eventClose
self.eventAcceptTarget = None
def __del__(self):
print("---------------------------------------------------------------------------- DELETE WHISPER DIALOG")
ui.ScriptWindow.__del__(self)
def LoadDialog(self):
try:
pyScrLoader = ui.PythonScriptLoader()
pyScrLoader.LoadScriptFile(self, "UIScript/WhisperDialog.py")
except:
import exception
exception.Abort("WhisperDialog.LoadDialog.LoadScript")
try:
GetObject=self.GetChild
self.titleName = GetObject("titlename")
self.titleNameEdit = GetObject("titlename_edit")
self.closeButton = GetObject("closebutton")
self.scrollBar = GetObject("scrollbar")
self.chatLine = GetObject("chatline")
self.minimizeButton = GetObject("minimizebutton")
self.ignoreButton = GetObject("ignorebutton")
self.reportViolentWhisperButton = GetObject("reportviolentwhisperbutton")
self.acceptButton = GetObject("acceptbutton")
self.sendButton = GetObject("sendbutton")
self.board = GetObject("board")
self.editBar = GetObject("editbar")
self.gamemasterMark = GetObject("gamemastermark")
except:
import exception
exception.Abort("DialogWindow.LoadDialog.BindObject")
self.gamemasterMark.Hide()
self.titleName.SetText("")
self.titleNameEdit.SetText("")
self.minimizeButton.SetEvent(ui.__mem_func__(self.Minimize))
self.closeButton.SetEvent(ui.__mem_func__(self.Close))
self.scrollBar.SetPos(1.0)
self.scrollBar.SetScrollEvent(ui.__mem_func__(self.OnScroll))
self.chatLine.SetReturnEvent(ui.__mem_func__(self.SendWhisper))
self.chatLine.SetEscapeEvent(ui.__mem_func__(self.Minimize))
self.chatLine.SetMultiLine()
self.sendButton.SetEvent(ui.__mem_func__(self.SendWhisper))
self.titleNameEdit.SetReturnEvent(ui.__mem_func__(self.AcceptTarget))
self.titleNameEdit.SetEscapeEvent(ui.__mem_func__(self.Close))
self.ignoreButton.SetToggleDownEvent(ui.__mem_func__(self.IgnoreTarget))
self.ignoreButton.SetToggleUpEvent(ui.__mem_func__(self.IgnoreTarget))
self.reportViolentWhisperButton.SetEvent(ui.__mem_func__(self.ReportViolentWhisper))
self.acceptButton.SetEvent(ui.__mem_func__(self.AcceptTarget))
self.textRenderer = self.TextRenderer()
self.textRenderer.SetParent(self)
self.textRenderer.SetPosition(20, 28)
self.textRenderer.SetTargetName("")
self.textRenderer.Show()
self.resizeButton = self.ResizeButton()
self.resizeButton.SetParent(self)
self.resizeButton.SetSize(20, 20)
self.resizeButton.SetPosition(280, 180)
self.resizeButton.SetMoveEvent(ui.__mem_func__(self.ResizeWhisperDialog))
self.resizeButton.Show()
self.ResizeWhisperDialog()
def Destroy(self):
self.eventMinimize = None
self.eventClose = None
self.eventAcceptTarget = None
self.ClearDictionary()
self.scrollBar.Destroy()
self.titleName = None
self.titleNameEdit = None
self.closeButton = None
self.scrollBar = None
self.chatLine = None
self.sendButton = None
self.ignoreButton = None
self.reportViolentWhisperButton = None
self.acceptButton = None
self.minimizeButton = None
self.textRenderer = None
self.board = None
self.editBar = None
self.resizeButton = None
def ResizeWhisperDialog(self):
(xPos, yPos) = self.resizeButton.GetLocalPosition()
if xPos < 280:
self.resizeButton.SetPosition(280, yPos)
return
if yPos < 150:
self.resizeButton.SetPosition(xPos, 150)
return
self.SetWhisperDialogSize(xPos + 20, yPos + 20)
def SetWhisperDialogSize(self, width, height):
try:
max = int((width-90)/6) * 3 - 6
self.board.SetSize(width, height)
self.scrollBar.SetPosition(width-25, 35)
self.scrollBar.SetScrollBarSize(height-100)
self.scrollBar.SetPos(1.0)
self.editBar.SetSize(width-18, 50)
self.chatLine.SetSize(width-90, 40)
self.chatLine.SetLimitWidth(width-90)
self.SetSize(width, height)
if 0 != self.targetName:
chat.SetWhisperBoxSize(self.targetName, width - 50, height - 90)
if app.IsRTL():
self.textRenderer.SetPosition(width-20, 28)
self.scrollBar.SetPosition(width-25+self.scrollBar.GetWidth(), 35)
self.editBar.SetPosition(10 + self.editBar.GetWidth(), height-60)
self.sendButton.SetPosition(width - 80 + self.sendButton.GetWidth(), 10)
self.minimizeButton.SetPosition(width-42 + self.minimizeButton.GetWidth(), 12)
self.closeButton.SetPosition(width-24+self.closeButton.GetWidth(), 12)
self.chatLine.SetPosition(5 + self.chatLine.GetWidth(), 5)
self.board.SetPosition(self.board.GetWidth(), 0)
else:
self.textRenderer.SetPosition(20, 28)
self.scrollBar.SetPosition(width-25, 35)
self.editBar.SetPosition(10, height-60)
self.sendButton.SetPosition(width-80, 10)
self.minimizeButton.SetPosition(width-42, 12)
self.closeButton.SetPosition(width-24, 12)
self.SetChatLineMax(max)
except:
import exception
exception.Abort("WhisperDialog.SetWhisperDialogSize.BindObject")
def SetChatLineMax(self, max):
self.chatLine.SetMax(max)
from grpText import GetSplitingTextLine
text = self.chatLine.GetText()
if text:
self.chatLine.SetText(GetSplitingTextLine(text, max, 0))
def OpenWithTarget(self, targetName):
chat.CreateWhisper(targetName)
chat.SetWhisperBoxSize(targetName, self.GetWidth() - 60, self.GetHeight() - 90)
self.chatLine.SetFocus()
self.titleName.SetText(targetName)
self.targetName = targetName
self.textRenderer.SetTargetName(targetName)
self.titleNameEdit.Hide()
self.ignoreButton.Hide()
self.reportViolentWhisperButton.Hide()
self.acceptButton.Hide()
self.gamemasterMark.Hide()
self.minimizeButton.Show()
def OpenWithoutTarget(self, event):
self.eventAcceptTarget = event
self.titleName.SetText("")
self.titleNameEdit.SetText("")
self.titleNameEdit.SetFocus()
self.targetName = 0
self.titleNameEdit.Show()
self.ignoreButton.Hide()
self.reportViolentWhisperButton.Hide()
self.acceptButton.Show()
self.minimizeButton.Hide()
self.gamemasterMark.Hide()
def SetGameMasterLook(self):
self.gamemasterMark.Show()
self.reportViolentWhisperButton.Hide()
def Minimize(self):
self.titleNameEdit.KillFocus()
self.chatLine.KillFocus()
self.Hide()
if None != self.eventMinimize:
self.eventMinimize(self.targetName)
def Close(self):
chat.ClearWhisper(self.targetName)
self.titleNameEdit.KillFocus()
self.chatLine.KillFocus()
self.Hide()
if None != self.eventClose:
self.eventClose(self.targetName)
def ReportViolentWhisper(self):
net.SendChatPacket("/reportviolentwhisper " + self.targetName)
def IgnoreTarget(self):
net.SendChatPacket("/ignore " + self.targetName)
def AcceptTarget(self):
name = self.titleNameEdit.GetText()
if len(name) <= 0:
self.Close()
return
if None != self.eventAcceptTarget:
self.titleNameEdit.KillFocus()
self.eventAcceptTarget(name)
def OnScroll(self):
chat.SetWhisperPosition(self.targetName, self.scrollBar.GetPos())
def SendWhisper(self):
text = self.chatLine.GetText()
textLength = len(text)
if textLength > 0:
if net.IsInsultIn(text):
chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.CHAT_INSULT_STRING)
return
net.SendWhisperPacket(self.targetName, text)
self.chatLine.SetText("")
chat.AppendWhisper(chat.WHISPER_TYPE_CHAT, self.targetName, player.GetName() + " : " + text)
def OnTop(self):
self.chatLine.SetFocus()
def BindInterface(self, interface):
self.interface = interface
def OnMouseLeftButtonDown(self):
hyperlink = ui.GetHyperlink()
if hyperlink:
if app.IsPressed(app.DIK_LALT):
link = chat.GetLinkFromHyperlink(hyperlink)
ime.PasteString(link)
else:
self.interface.MakeHyperlinkTooltip(hyperlink)
if "__main__" == __name__:
import uiTest
class TestApp(uiTest.App):
def OnInit(self):
wnd = WhisperDialog(self.OnMax, self.OnMin)
wnd.LoadDialog()
wnd.OpenWithoutTarget(self.OnNew)
wnd.SetPosition(0, 0)
wnd.Show()
self.wnd = wnd
def OnMax(self):
pass
def OnMin(self):
pass
def OnNew(self):
pass
TestApp().MainLoop()
-66
View File
@@ -1,66 +0,0 @@
class Sandbox(object):
# DO NOT REMOVE ANY ENTRY OF WHITE LIST
# THIS ENTIES ARE USED FOR Sandbox.
# (If sys.modules['__main__'] is changed, you can see the hell.)
WHITE_LIST = ['__builtin__', 'types', __name__, '__main__', 'sys']
def __init__(self, prevent_imported_modules = False, allowed_modules = [], prevented_modules = [], allowed_paths = []):
self.prevent_imported_modules = prevent_imported_modules
self.allowed_modules = allowed_modules
self.prevented_modules = prevented_modules
self.allowed_paths = allowed_paths
def add_allowed_modules(self, allowed_modules):
self.allowed_modules = self.allowed_modules + allowed_modules
def add_prevented_modules(self, prevented_modules):
self.prevented_modules = self.prevented_modules + prevented_modules
def execfile(self, filename, dic):
import sys
import copy
for allowed_module_name in self.allowed_modules:
try:
exec('import {0}'.format(allowed_module_name))
except:
# Just now, pass the exception.
# (filename could not use this module)
sys.stderr.write("Could not import %s" % allowed_module_name)
pass
# shallow copy of sys.modules
old_modules = copy.copy(sys.modules)
old_path = sys.path
sys.path = self.allowed_paths
# set current imported modules None
if self.prevent_imported_modules:
import types
for k, v in list(old_modules.items()):
if type(v) == types.ModuleType:
if not (k in self.WHITE_LIST or k in self.allowed_modules):
sys.modules[k] = None
# set prevented modules None.
for prevented_module_name in self.prevented_modules:
sys.modules[prevented_module_name] = None
try:
with open(filename, 'rb') as f:
data = f.read()
code = compile(data, filename, 'exec')
exec(code, dic)
except Exception as e:
sys.stderr.write(e)
finally:
# Restore original settings.
#sys.modules = old_modules# <- This is not effective. I don't know why, but I guess some where got old sys.modules reference and access old one.
for k, v in list(sys.modules.items()):
if not k in old_modules:
del sys.modules[k]
for k, v in list(old_modules.items()):
sys.modules[k] = v
sys.path = old_path