Commit 8b987b97 authored by mercury233's avatar mercury233

Merge branch 'master' of https://github.com/Fluorohydride/ygopro

parents 56cb90aa a2aac58a
# ygopro
## YGOPro
[![Build Status](https://travis-ci.org/moecube/ygopro.svg?branch=master)](https://travis-ci.org/moecube/ygopro) [![Build status](https://ci.appveyor.com/api/projects/status/qgkqi6o0wq7qn922?svg=true)](https://ci.appveyor.com/project/zh99998/ygopro)
A script engine for "yu-gi-oh!" and sample gui
[中文说明](https://github.com/Fluorohydride/ygopro/wiki/%E4%B8%AD%E6%96%87%E8%AF%B4%E6%98%8E)
###Keys:
### Keys:
* ESC: Minimize the window.
* A: Holding down this button will let the system stop at every timing.
* S: Holding down this button will let the system skip every timing.
* R: Fix the font error.
* D: Holding down this button will let the system stop at available timing.
* R: Fix the font glitch.
* F1~F4: Show the cards in your grave, banished zone, extra deck, xyz materials.
* F5~F8: Show the cards in your opponent's grave, banished zone, extra deck, xyz materials.
###Color in card list:
####Background:
### Color in card list:
#### Background:
* White = your card, Grey = your opponent's card
####Text:
#### Text:
Cards in deck, extra deck and banished zone:
* Black = face-up, Blue = face-down
Xyz materials:
* Black = default, Blue = the owner of the xyz material is different from its controller
###Sequence:
### Sequence:
* Monster Zone: 1~5, starting from the left hand side.
* Spell & Trap Zone: 1~5, starting from the left hand side.
* Field Zone: 6
* Pendulum Zone: 7~8, starting from the left hand side.
* Pendulum Zone: 0~1, starting from the left hand side.
* The others: 1~n, starting from the bottom.
###Deck edit page:
### Deck edit page:
* All numeric textboxs: They support >, =, <, >=, <= signs.
* Card name: Search card names and texts by default, $foo will only search foo in card names, and @foo will search cards of "foo" archetype(due to translation, card name contains "foo" does not mean that card is "foo" card).
### Command-line options:
* -j: Join the host in system.conf file.
* -d: Enter the deck edit page.
* -r: Enter the replay mode page.
* -s: Enter the single mode page.
* -efoo: Load foo as the extra database.
* `-e foo.cdb`: Load foo.cdb as the extra database.
* `-n nickname`: Set the nickname.
* `-h 192.168.0.2`: Set the host to join in LAN mode.
* `-p 7911`: Set the port to join in LAN mode.
* `-w abc`: Set the password to join in LAN mode.
* `-d`: Enter the deck edit page.
* `-d deck`: If used along with `-j` it mean select the deck, or it will open the deck to edit.
* `-c`: Create host with default settings.
* `-j`: Join the host specified in above, or if absent, lasthost in system.conf file.
* `-r`: Enter the replay mode page.
* `-r replay.yrp`: Load the replay.yrp in replay mode.
* `-s`: Enter the single mode page.
* `-s puzzle.lua`: Load the puzzle.lua in single mode.
* `-k`: Keep when duel finished. See below.
#### Note:
* `-c` `-j` `-e` `-r` `-s` shoule be the last parameter, because any parameters after it will get ignored.
* `-d` `-c` `-j` `-e` `-r` `-s` will make YGOPro automatically exit when the duel or deck editing is finished. This is useful for some launchers. If you want to keep it, add `-k` before them.
* `-d` `-r` `-s` support full path of file, or just filename. But remember deck filename should NOT have extension when replay and single filename MUST have extension.
### Directories:
* pics: .jpg card images(177*254).
......
......@@ -16,6 +16,7 @@ ClientCard::ClientCard() {
is_selected = false;
is_showequip = false;
is_showtarget = false;
is_showchaintarget = false;
is_highlighting = false;
is_disabled = false;
is_reversed = false;
......@@ -27,6 +28,7 @@ ClientCard::ClientCard() {
alias = 0;
level = 0;
rank = 0;
link = 0;
race = 0;
attribute = 0;
attack = 0;
......@@ -35,11 +37,13 @@ ClientCard::ClientCard() {
base_defense = 0;
lscale = 0;
rscale = 0;
link_marker = 0;
cHint = 0;
chValue = 0;
atkstring[0] = 0;
defstring[0] = 0;
lvstring[0] = 0;
linkstring[0] = 0;
rscstring[0] = 0;
lscstring[0] = 0;
overlayTarget = 0;
......@@ -101,7 +105,10 @@ void ClientCard::UpdateInfo(char* buf) {
}
if(flag & QUERY_DEFENSE) {
defense = BufferIO::ReadInt32(buf);
if(defense < 0) {
if(type & TYPE_LINK) {
defstring[0] = '-';
defstring[1] = 0;
} else if(defense < 0) {
defstring[0] = '?';
defstring[1] = 0;
} else
......@@ -162,6 +169,17 @@ void ClientCard::UpdateInfo(char* buf) {
rscale = BufferIO::ReadInt32(buf);
myswprintf(rscstring, L"%d", rscale);
}
if(flag & QUERY_LINK) {
pdata = BufferIO::ReadInt32(buf);
if (link != (unsigned int)pdata) {
link = pdata;
}
myswprintf(linkstring, L"L\x2012%d", link);
pdata = BufferIO::ReadInt32(buf);
if (link_marker != (unsigned int)pdata) {
link_marker = pdata;
}
}
}
void ClientCard::ClearTarget() {
for(auto cit = cardTarget.begin(); cit != cardTarget.end(); ++cit) {
......@@ -197,8 +215,8 @@ bool ClientCard::deck_sort_lv(code_pointer p1, code_pointer p2) {
if((p1->second.type & 0x7) != (p2->second.type & 0x7))
return (p1->second.type & 0x7) < (p2->second.type & 0x7);
if((p1->second.type & 0x7) == 1) {
int type1 = (p1->second.type & 0x8020c0) ? (p1->second.type & 0x8020c1) : (p1->second.type & 0x31);
int type2 = (p2->second.type & 0x8020c0) ? (p2->second.type & 0x8020c1) : (p2->second.type & 0x31);
int type1 = (p1->second.type & 0x48020c0) ? (p1->second.type & 0x48020c1) : (p1->second.type & 0x31);
int type2 = (p2->second.type & 0x48020c0) ? (p2->second.type & 0x48020c1) : (p2->second.type & 0x31);
if(type1 != type2)
return type1 < type2;
if(p1->second.level != p2->second.level)
......@@ -223,8 +241,8 @@ bool ClientCard::deck_sort_atk(code_pointer p1, code_pointer p2) {
return p1->second.defense > p2->second.defense;
if(p1->second.level != p2->second.level)
return p1->second.level > p2->second.level;
int type1 = (p1->second.type & 0x8020c0) ? (p1->second.type & 0x8020c1) : (p1->second.type & 0x31);
int type2 = (p2->second.type & 0x8020c0) ? (p2->second.type & 0x8020c1) : (p2->second.type & 0x31);
int type1 = (p1->second.type & 0x48020c0) ? (p1->second.type & 0x48020c1) : (p1->second.type & 0x31);
int type2 = (p2->second.type & 0x48020c0) ? (p2->second.type & 0x48020c1) : (p2->second.type & 0x31);
if(type1 != type2)
return type1 < type2;
return p1->first < p2->first;
......@@ -243,8 +261,8 @@ bool ClientCard::deck_sort_def(code_pointer p1, code_pointer p2) {
return p1->second.attack > p2->second.attack;
if(p1->second.level != p2->second.level)
return p1->second.level > p2->second.level;
int type1 = (p1->second.type & 0x8020c0) ? (p1->second.type & 0x8020c1) : (p1->second.type & 0x31);
int type2 = (p2->second.type & 0x8020c0) ? (p2->second.type & 0x8020c1) : (p2->second.type & 0x31);
int type1 = (p1->second.type & 0x48020c0) ? (p1->second.type & 0x48020c1) : (p1->second.type & 0x31);
int type2 = (p2->second.type & 0x48020c0) ? (p2->second.type & 0x48020c1) : (p2->second.type & 0x31);
if(type1 != type2)
return type1 < type2;
return p1->first < p2->first;
......
......@@ -20,6 +20,7 @@ struct CardData {
int defense;
unsigned int lscale;
unsigned int rscale;
unsigned int link_marker;
};
struct CardDataC {
unsigned int code;
......@@ -33,6 +34,7 @@ struct CardDataC {
int defense;
unsigned int lscale;
unsigned int rscale;
unsigned int link_marker;
unsigned int ot;
unsigned int category;
};
......@@ -45,7 +47,6 @@ typedef std::unordered_map<unsigned int, CardDataC>::const_iterator code_pointer
class ClientCard {
public:
irr::video::ITexture* curTexture;
irr::core::matrix4 mTransform;
irr::core::vector3df curPos;
irr::core::vector3df curRot;
......@@ -61,6 +62,7 @@ public:
bool is_selected;
bool is_showequip;
bool is_showtarget;
bool is_showchaintarget;
bool is_highlighting;
bool is_reversed;
u32 code;
......@@ -69,6 +71,7 @@ public:
u32 type;
u32 level;
u32 rank;
u32 link;
u32 attribute;
u32 race;
s32 attack;
......@@ -77,6 +80,7 @@ public:
s32 base_defense;
u32 lscale;
u32 rscale;
u32 link_marker;
u32 reason;
u32 select_seq;
u8 owner;
......@@ -102,6 +106,7 @@ public:
wchar_t atkstring[16];
wchar_t defstring[16];
wchar_t lvstring[16];
wchar_t linkstring[16];
wchar_t lscstring[16];
wchar_t rscstring[16];
......
This diff is collapsed.
......@@ -3,12 +3,13 @@
#include "config.h"
#include <vector>
#include <set>
namespace ygo {
class ClientCard;
struct ChainInfo{
struct ChainInfo {
irr::core::vector3df chain_pos;
ClientCard* chain_card;
int code;
......@@ -17,6 +18,7 @@ struct ChainInfo{
int location;
int sequence;
bool solved;
std::set<ClientCard*> target;
};
class ClientField: public irr::IEventReceiver {
......@@ -41,7 +43,7 @@ public:
std::vector<int> select_options;
std::vector<ChainInfo> chains;
int extra_p_count[2];
size_t selected_option;
ClientCard* attacker;
ClientCard* attack_target;
......@@ -79,7 +81,7 @@ public:
bool last_chain;
bool deck_reversed;
bool conti_selecting;
ClientField();
void Clear();
void Initial(int player, int deckc, int extrac);
......@@ -96,7 +98,7 @@ public:
void ShowLocationCard();
void ReplaySwap();
void RefreshAllCards();
void GetChainLocation(int controler, int location, int sequence, irr::core::vector3df* t);
void GetCardLocation(ClientCard* pcard, irr::core::vector3df* t, irr::core::vector3df* r, bool setTrans = false);
void MoveCard(ClientCard* pcard, int frame);
......@@ -128,10 +130,12 @@ public:
int list_command;
virtual bool OnEvent(const irr::SEvent& event);
virtual bool OnCommonEvent(const irr::SEvent& event);
void GetHoverField(int x, int y);
void ShowMenu(int flag, int x, int y);
void UpdateChainButtons();
void ShowCancelOrFinishButton(int buttonOp);
void SetShowMark(ClientCard* pcard, bool enable);
void SetResponseSelectedCards() const;
};
......
......@@ -4,7 +4,7 @@
#pragma once
#define _IRR_STATIC_LIB_
#define _IRR_COMPILE_WITH_DX9_DEV_PACK
#define IRR_COMPILE_WITH_DX9_DEV_PACK
#ifdef _WIN32
#include <WinSock2.h>
......
......@@ -31,6 +31,11 @@ bool DataManager::LoadDB(const char* file) {
cd.type = sqlite3_column_int(pStmt, 4);
cd.attack = sqlite3_column_int(pStmt, 5);
cd.defense = sqlite3_column_int(pStmt, 6);
if(cd.type & TYPE_LINK) {
cd.link_marker = cd.defense;
cd.defense = 0;
} else
cd.link_marker = 0;
unsigned int level = sqlite3_column_int(pStmt, 7);
cd.level = level & 0xff;
cd.lscale = (level >> 24) & 0xff;
......@@ -84,28 +89,20 @@ bool DataManager::LoadStrings(const char* file) {
sscanf(linebuf, "!%s", strbuf);
if(!strcmp(strbuf, "system")) {
sscanf(&linebuf[7], "%d %240[^\n]", &value, strbuf);
int len = BufferIO::DecodeUTF8(strbuf, strBuffer);
wchar_t* pbuf = new wchar_t[len + 1];
wcscpy(pbuf, strBuffer);
_sysStrings[value] = pbuf;
BufferIO::DecodeUTF8(strbuf, strBuffer);
_sysStrings[value] = strBuffer;
} else if(!strcmp(strbuf, "victory")) {
sscanf(&linebuf[8], "%x %240[^\n]", &value, strbuf);
int len = BufferIO::DecodeUTF8(strbuf, strBuffer);
wchar_t* pbuf = new wchar_t[len + 1];
wcscpy(pbuf, strBuffer);
_victoryStrings[value] = pbuf;
BufferIO::DecodeUTF8(strbuf, strBuffer);
_victoryStrings[value] = strBuffer;
} else if(!strcmp(strbuf, "counter")) {
sscanf(&linebuf[8], "%x %240[^\n]", &value, strbuf);
int len = BufferIO::DecodeUTF8(strbuf, strBuffer);
wchar_t* pbuf = new wchar_t[len + 1];
wcscpy(pbuf, strBuffer);
_counterStrings[value] = pbuf;
BufferIO::DecodeUTF8(strbuf, strBuffer);
_counterStrings[value] = strBuffer;
} else if(!strcmp(strbuf, "setname")) {
sscanf(&linebuf[8], "%x %240[^\t\n]", &value, strbuf);//using tab for comment
int len = BufferIO::DecodeUTF8(strbuf, strBuffer);
wchar_t* pbuf = new wchar_t[len + 1];
wcscpy(pbuf, strBuffer);
_setnameStrings[value] = pbuf;
BufferIO::DecodeUTF8(strbuf, strBuffer);
_setnameStrings[value] = strBuffer;
}
}
fclose(fp);
......@@ -170,33 +167,35 @@ const wchar_t* DataManager::GetDesc(int strCode) {
return unknown_string;
}
const wchar_t* DataManager::GetSysString(int code) {
if(code < 0 || code >= 2048 || _sysStrings[code] == 0)
if(code < 0 || code >= 2048)
return unknown_string;
return _sysStrings[code];
auto csit = _sysStrings.find(code);
if(csit == _sysStrings.end())
return unknown_string;
return csit->second.c_str();
}
const wchar_t* DataManager::GetVictoryString(int code) {
auto csit = _victoryStrings.find(code);
if(csit == _victoryStrings.end())
return unknown_string;
return csit->second;
return csit->second.c_str();
}
const wchar_t* DataManager::GetCounterName(int code) {
auto csit = _counterStrings.find(code);
if(csit == _counterStrings.end())
return unknown_string;
return csit->second;
return csit->second.c_str();
}
const wchar_t* DataManager::GetSetName(int code) {
auto csit = _setnameStrings.find(code);
if(csit == _setnameStrings.end())
return NULL;
return csit->second;
return csit->second.c_str();
}
unsigned int DataManager::GetSetCode(const wchar_t* setname) {
wchar_t strbuff[256];
for(auto csit = _setnameStrings.begin(); csit != _setnameStrings.end(); ++csit) {
swscanf(csit->second, L"%[^|]", strbuff);//setname|extra info
if(wcscmp(strbuff, setname) == 0)
auto xpos = csit->second.find_first_of(L'|');//setname|extra info
if(csit->second.compare(0, xpos, setname) == 0)
return csit->first;
}
return 0;
......@@ -267,7 +266,7 @@ const wchar_t* DataManager::FormatType(int type) {
wchar_t* p = tpBuffer;
unsigned filter = 1;
int i = 1050;
for(; filter != 0x4000000; filter <<= 1, ++i) {
for(; filter != 0x8000000; filter <<= 1, ++i) {
if(type & filter) {
BufferIO::CopyWStrRef(GetSysString(i), p, 16);
*p = L'|';
......@@ -285,7 +284,7 @@ const wchar_t* DataManager::FormatSetName(unsigned long long setcode) {
for(int i = 0; i < 4; ++i) {
const wchar_t* setname = GetSetName((setcode >> i * 16) & 0xffff);
if(setname) {
BufferIO::CopyWStrRef(setname, p, 16);
BufferIO::CopyWStrRef(setname, p, 32);
*p = L'|';
*++p = 0;
}
......@@ -296,6 +295,27 @@ const wchar_t* DataManager::FormatSetName(unsigned long long setcode) {
return unknown_string;
return scBuffer;
}
const wchar_t* DataManager::FormatLinkMarker(int link_marker) {
wchar_t* p = lmBuffer;
*p = 0;
if(link_marker & LINK_MARKER_TOP_LEFT)
BufferIO::CopyWStrRef(L"[\u2196]", p, 4);
if(link_marker & LINK_MARKER_TOP)
BufferIO::CopyWStrRef(L"[\u2191]", p, 4);
if(link_marker & LINK_MARKER_TOP_RIGHT)
BufferIO::CopyWStrRef(L"[\u2197]", p, 4);
if(link_marker & LINK_MARKER_LEFT)
BufferIO::CopyWStrRef(L"[\u2190]", p, 4);
if(link_marker & LINK_MARKER_RIGHT)
BufferIO::CopyWStrRef(L"[\u2192]", p, 4);
if(link_marker & LINK_MARKER_BOTTOM_LEFT)
BufferIO::CopyWStrRef(L"[\u2199]", p, 4);
if(link_marker & LINK_MARKER_BOTTOM)
BufferIO::CopyWStrRef(L"[\u2193]", p, 4);
if(link_marker & LINK_MARKER_BOTTOM_RIGHT)
BufferIO::CopyWStrRef(L"[\u2198]", p, 4);
return lmBuffer;
}
int DataManager::CardReader(int code, void* pData) {
if(!dataManager.GetData(code, (CardData*)pData))
memset(pData, 0, sizeof(CardData));
......
......@@ -31,25 +31,27 @@ public:
const wchar_t* FormatRace(int race);
const wchar_t* FormatType(int type);
const wchar_t* FormatSetName(unsigned long long setcode);
const wchar_t* FormatLinkMarker(int link_marker);
std::unordered_map<unsigned int, CardDataC> _datas;
std::unordered_map<unsigned int, CardString> _strings;
std::unordered_map<unsigned int, wchar_t*> _counterStrings;
std::unordered_map<unsigned int, wchar_t*> _victoryStrings;
std::unordered_map<unsigned int, wchar_t*> _setnameStrings;
std::unordered_map<unsigned int, std::wstring> _counterStrings;
std::unordered_map<unsigned int, std::wstring> _victoryStrings;
std::unordered_map<unsigned int, std::wstring> _setnameStrings;
std::unordered_map<unsigned int, std::wstring> _sysStrings;
wchar_t* _sysStrings[2048];
wchar_t numStrings[256][4];
wchar_t numBuffer[6];
wchar_t attBuffer[128];
wchar_t racBuffer[128];
wchar_t tpBuffer[128];
wchar_t scBuffer[128];
wchar_t lmBuffer[32];
static wchar_t strBuffer[4096];
static const wchar_t* unknown_string;
static int CardReader(int, void*);
};
extern DataManager dataManager;
......
This diff is collapsed.
......@@ -11,11 +11,25 @@ namespace ygo {
class DeckBuilder: public irr::IEventReceiver {
public:
virtual bool OnEvent(const irr::SEvent& event);
void Initialize();
void Terminate();
void GetHoveredCard();
void FilterCards();
void StartFilter();
void ClearFilter();
void ClearSearch();
void SortList();
bool CardNameContains(const wchar_t *haystack, const wchar_t *needle);
bool push_main(code_pointer pointer, int seq = -1);
bool push_extra(code_pointer pointer, int seq = -1);
bool push_side(code_pointer pointer, int seq = -1);
void pop_main(int seq);
void pop_extra(int seq);
void pop_side(int seq);
bool check_limit(code_pointer pointer);
long long filter_effect;
unsigned int filter_type;
unsigned int filter_type2;
......@@ -29,7 +43,9 @@ public:
unsigned int filter_lv;
unsigned int filter_scltype;
unsigned int filter_scl;
unsigned int filter_marks;
int filter_lm;
position2di mouse_pos;
int hovered_code;
int hovered_pos;
int hovered_seq;
......@@ -41,9 +57,10 @@ public:
size_t pre_extrac;
size_t pre_sidec;
code_pointer draging_pointer;
bool is_deleting;
bool is_clearing;
int prev_deck;
s32 prev_operation;
bool is_modified;
std::unordered_map<int, int>* filterList;
std::vector<code_pointer> results;
wchar_t result_string[8];
......
......@@ -84,7 +84,7 @@ int DeckManager::CheckLFList(Deck& deck, int lfhash, bool allow_ocg, bool allow_
code_pointer cit = deck.main[i];
if((!allow_ocg && (cit->second.ot == 0x1)) || (!allow_tcg && (cit->second.ot == 0x2)))
return cit->first;
if(cit->second.type & (TYPE_FUSION | TYPE_SYNCHRO | TYPE_XYZ | TYPE_TOKEN))
if(cit->second.type & (TYPE_FUSION | TYPE_SYNCHRO | TYPE_XYZ | TYPE_TOKEN | TYPE_LINK))
return 1;
int code = cit->second.alias ? cit->second.alias : cit->first;
ccount[code]++;
......@@ -127,7 +127,7 @@ void DeckManager::LoadDeck(Deck& deck, int* dbuf, int mainc, int sidec) {
continue;
if(cd.type & TYPE_TOKEN)
continue;
else if(cd.type & 0x802040 && deck.extra.size() < 15) {
else if(cd.type & (TYPE_FUSION | TYPE_SYNCHRO | TYPE_XYZ | TYPE_LINK) && deck.extra.size() < 15) {
deck.extra.push_back(dataManager.GetCodePointer(code)); //verified by GetData()
} else if(deck.main.size() < 60) {
deck.main.push_back(dataManager.GetCodePointer(code));
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -25,7 +25,8 @@ struct Config {
wchar_t numfont[256];
wchar_t roompass[20];
//settings
int chkAutoPos;
int chkMAutoPos;
int chkSTAutoPos;
int chkRandomPos;
int chkAutoChain;
int chkWaitChain;
......@@ -36,6 +37,8 @@ struct Config {
int control_mode;
int draw_field_spell;
int separate_clear_button;
int auto_search_limit;
int chkIgnoreDeckChanges;
};
struct DuelInfo {
......@@ -48,6 +51,7 @@ struct DuelInfo {
bool is_shuffling;
bool tag_player[2];
int lp[2];
int duel_rule;
int turn;
short curMsg;
wchar_t hostname[20];
......@@ -88,11 +92,15 @@ public:
void RefreshSingleplay();
void DrawSelectionLine(irr::video::S3DVertex* vec, bool strip, int width, float* cv);
void DrawBackGround();
void DrawLinkedZones(ClientCard* pcard);
void CheckMutual(ClientCard* pcard, int mark);
void DrawCards();
void DrawCard(ClientCard* pcard);
void DrawMisc();
void DrawStatus(ClientCard* pcard, int x1, int y1, int x2, int y2);
void DrawGUI();
void DrawSpec();
void DrawBackImage(irr::video::ITexture* texture);
void ShowElement(irr::gui::IGUIElement* element, int autoframe = 0);
void HideElement(irr::gui::IGUIElement* element, bool set_action = false);
void PopupElement(irr::gui::IGUIElement* element, int hideframe = 0);
......@@ -103,6 +111,7 @@ public:
void SaveConfig();
void ShowCardInfo(int code);
void AddChatMsg(wchar_t* msg, int player);
void AddDebugMsg(char* msgbuf);
void ClearTextures();
void CloseDuelWindow();
......@@ -196,12 +205,15 @@ public:
irr::gui::IGUIStaticText* stSetName;
irr::gui::IGUIStaticText* stText;
irr::gui::IGUIScrollBar* scrCardText;
irr::gui::IGUICheckBox* chkAutoPos;
irr::gui::IGUICheckBox* chkMAutoPos;
irr::gui::IGUICheckBox* chkSTAutoPos;
irr::gui::IGUICheckBox* chkRandomPos;
irr::gui::IGUICheckBox* chkAutoChain;
irr::gui::IGUICheckBox* chkWaitChain;
irr::gui::IGUICheckBox* chkHideSetname;
irr::gui::IGUICheckBox* chkHideHintButton;
irr::gui::IGUICheckBox* chkIgnoreDeckChanges;
irr::gui::IGUICheckBox* chkAutoSearch;
irr::gui::IGUIListBox* lstLog;
irr::gui::IGUIButton* btnClearLog;
irr::gui::IGUIButton* btnSaveLog;
......@@ -235,7 +247,7 @@ public:
irr::gui::IGUIEditBox* ebDrawCount;
irr::gui::IGUIEditBox* ebServerName;
irr::gui::IGUIEditBox* ebServerPass;
irr::gui::IGUICheckBox* chkEnablePriority;
irr::gui::IGUIComboBox* cbDuelRule;
irr::gui::IGUICheckBox* chkNoCheckDeck;
irr::gui::IGUICheckBox* chkNoShuffleDeck;
irr::gui::IGUIButton* btnHostConfirm;
......@@ -344,9 +356,7 @@ public:
irr::gui::IGUICheckBox* chkIgnore2;
//phase button
irr::gui::IGUIStaticText* wPhase;
irr::gui::IGUIButton* btnDP;
irr::gui::IGUIButton* btnSP;
irr::gui::IGUIButton* btnM1;
irr::gui::IGUIButton* btnPhaseStatus;
irr::gui::IGUIButton* btnBP;
irr::gui::IGUIButton* btnM2;
irr::gui::IGUIButton* btnEP;
......@@ -381,6 +391,10 @@ public:
irr::gui::IGUIWindow* wCategories;
irr::gui::IGUICheckBox* chkCategory[32];
irr::gui::IGUIButton* btnCategoryOK;
irr::gui::IGUIButton* btnMarksFilter;
irr::gui::IGUIWindow* wLinkMarks;
irr::gui::IGUIButton* btnMark[8];
irr::gui::IGUIButton* btnMarksOK;
//sort type
irr::gui::IGUIStaticText* wSort;
irr::gui::IGUIComboBox* cbSortType;
......@@ -399,6 +413,8 @@ public:
irr::gui::IGUIButton* btnReplaySwap;
//surrender/leave
irr::gui::IGUIButton* btnLeaveGame;
//swap
irr::gui::IGUIButton* btnSpectatorSwap;
//chain control
irr::gui::IGUIButton* btnChainIgnore;
irr::gui::IGUIButton* btnChainAlways;
......@@ -496,6 +512,7 @@ extern Game* mainGame;
#define BUTTON_CHAIN_ALWAYS 265
#define BUTTON_CHAIN_WHENAVAIL 266
#define BUTTON_CANCEL_OR_FINISH 267
#define BUTTON_PHASE 268
#define BUTTON_CLEAR_LOG 270
#define LISTBOX_LOG 271
#define SCROLL_CARDTEXT 280
......@@ -518,11 +535,12 @@ extern Game* mainGame;
#define BUTTON_SIDE_OK 309
#define BUTTON_SHUFFLE_DECK 310
#define COMBOBOX_MAINTYPE 311
#define BUTTON_EFFECT_FILTER 312
#define BUTTON_START_FILTER 313
#define SCROLL_FILTER 314
#define EDITBOX_KEYWORD 315
#define BUTTON_CLEAR_FILTER 316
#define COMBOBOX_SECONDTYPE 312
#define BUTTON_EFFECT_FILTER 313
#define BUTTON_START_FILTER 314
#define SCROLL_FILTER 315
#define EDITBOX_KEYWORD 316
#define BUTTON_CLEAR_FILTER 317
#define BUTTON_REPLAY_START 320
#define BUTTON_REPLAY_PAUSE 321
#define BUTTON_REPLAY_STEP 322
......@@ -534,5 +552,11 @@ extern Game* mainGame;
#define LISTBOX_SINGLEPLAY_LIST 350
#define BUTTON_LOAD_SINGLEPLAY 351
#define BUTTON_CANCEL_SINGLEPLAY 352
#define CHECKBOX_AUTO_SEARCH 360
#define COMBOBOX_SORTTYPE 370
#define BUTTON_MARKS_FILTER 380
#define BUTTON_MARKERS_OK 381
#define DEFAULT_DUEL_RULE 4
#endif // GAME_H
......@@ -94,19 +94,30 @@ int main(int argc, char* argv[]) {
} else if(!strcmp(argv[i], "-k")) { // Keep on return
exit_on_return = false;
keep_on_return = true;
} else if(!strcmp(argv[i], "-d")) { // Deck
if(i + 2 < argc) { // select deck
++i;
GetParameterW(ygo::mainGame->gameConf.lastdeck, &argv[i][0]);
continue;
} else { // open deck
exit_on_return = !keep_on_return;
if(i < argc) {
open_file = true;
GetParameterW(open_file_name, &argv[i + 1][0]);
}
ClickButton(ygo::mainGame->btnDeckEdit);
break;
}
} else if(!strcmp(argv[i], "-c")) { // Create host
exit_on_return = !keep_on_return;
ygo::mainGame->HideElement(ygo::mainGame->wMainMenu);
ClickButton(ygo::mainGame->btnHostConfirm);
break;
} else if(!strcmp(argv[i], "-j")) { // Join host
exit_on_return = !keep_on_return;
ClickButton(ygo::mainGame->btnLanMode);
ClickButton(ygo::mainGame->btnJoinHost);
break;
} else if(!strcmp(argv[i], "-d")) { // Deck
exit_on_return = !keep_on_return;
if(i < argc) {
open_file = true;
GetParameterW(open_file_name, &argv[i + 1][0]);
}
ClickButton(ygo::mainGame->btnDeckEdit);
break;
} else if(!strcmp(argv[i], "-r")) { // Replay
exit_on_return = !keep_on_return;
if(i < argc) {
......
......@@ -7,6 +7,8 @@ ImageManager imageManager;
bool ImageManager::Initial() {
tCover[0] = driver->getTexture("textures/cover.jpg");
tCover[1] = driver->getTexture("textures/cover2.jpg");
if(!tCover[1])
tCover[1] = tCover[0];
tUnknown = driver->getTexture("textures/unknown.jpg");
tAct = driver->getTexture("textures/act.png");
tAttack = driver->getTexture("textures/attack.png");
......@@ -18,6 +20,7 @@ bool ImageManager::Initial() {
tMask = driver->getTexture("textures/mask.png");
tEquip = driver->getTexture("textures/equip.png");
tTarget = driver->getTexture("textures/target.png");
tChainTarget = driver->getTexture("textures/chaintarget.png");
tLim = driver->getTexture("textures/lim.png");
tOT = driver->getTexture("textures/ot.png");
tHand[0] = driver->getTexture("textures/f1.jpg");
......@@ -25,9 +28,15 @@ bool ImageManager::Initial() {
tHand[2] = driver->getTexture("textures/f3.jpg");
tBackGround = driver->getTexture("textures/bg.jpg");
tBackGround_menu = driver->getTexture("textures/bg_menu.jpg");
if(!tBackGround_menu)
tBackGround_menu = tBackGround;
tBackGround_deck = driver->getTexture("textures/bg_deck.jpg");
tField = driver->getTexture("textures/field2.png");
tFieldTransparent = driver->getTexture("textures/field-transparent2.png");
if(!tBackGround_deck)
tBackGround_deck = tBackGround;
tField[0] = driver->getTexture("textures/field2.png");
tFieldTransparent[0] = driver->getTexture("textures/field-transparent2.png");
tField[1] = driver->getTexture("textures/field3.png");
tFieldTransparent[1] = driver->getTexture("textures/field-transparent3.png");
return true;
}
void ImageManager::SetDevice(irr::IrrlichtDevice* dev) {
......
......@@ -34,14 +34,15 @@ public:
irr::video::ITexture* tMask;
irr::video::ITexture* tEquip;
irr::video::ITexture* tTarget;
irr::video::ITexture* tChainTarget;
irr::video::ITexture* tLim;
irr::video::ITexture* tOT;
irr::video::ITexture* tHand[3];
irr::video::ITexture* tBackGround;
irr::video::ITexture* tBackGround_menu;
irr::video::ITexture* tBackGround_deck;
irr::video::ITexture* tField;
irr::video::ITexture* tFieldTransparent;
irr::video::ITexture* tField[2];
irr::video::ITexture* tFieldTransparent[2];
};
extern ImageManager imageManager;
......
This diff is collapsed.
......@@ -19,12 +19,18 @@ public:
S3DVertex vFieldSpell[4];
S3DVertex vFieldSpell1[4];
S3DVertex vFieldSpell2[4];
S3DVertex vBackLine[76];
S3DVertex vFields[140];
//S3DVertex vBackLine[76];
S3DVertex vFieldDeck[2][4];
S3DVertex vFieldGrave[2][2][4];
S3DVertex vFieldExtra[2][4];
S3DVertex vFieldRemove[2][2][4];
S3DVertex vFieldMzone[2][7][4];
S3DVertex vFieldSzone[2][8][2][4];
irr::core::vector3df vFieldContiAct[4];
S3DVertex vArrow[40];
SColor c2d[4];
u16 iRectangle[6];
u16 iBackLine[116];
//u16 iBackLine[116];
u16 iArrow[40];
irr::video::SMaterial mCard;
irr::video::SMaterial mTexture;
......
......@@ -108,6 +108,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
break;
}
case BUTTON_HP_DUELIST: {
mainGame->cbDeckSelect->setEnabled(true);
DuelClient::SendPacketToServer(CTOS_HS_TODUELIST);
break;
}
......@@ -243,43 +244,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
mainGame->ebDeckname->setText(L"");
}
mainGame->HideElement(mainGame->wMainMenu);
mainGame->is_building = true;
mainGame->is_siding = false;
mainGame->wInfos->setVisible(true);
mainGame->wCardImg->setVisible(true);
mainGame->wDeckEdit->setVisible(true);
mainGame->wFilter->setVisible(true);
mainGame->wSort->setVisible(true);
mainGame->btnLeaveGame->setVisible(true);
mainGame->btnLeaveGame->setText(dataManager.GetSysString(1306));
mainGame->btnSideOK->setVisible(false);
mainGame->deckBuilder.filterList = deckManager._lfList[0].content;
mainGame->cbDBLFList->setSelected(0);
mainGame->cbCardType->setSelected(0);
mainGame->cbCardType2->setSelected(0);
mainGame->cbAttribute->setSelected(0);
mainGame->cbRace->setSelected(0);
mainGame->ebAttack->setText(L"");
mainGame->ebDefense->setText(L"");
mainGame->ebStar->setText(L"");
mainGame->ebScale->setText(L"");
mainGame->cbCardType2->setEnabled(false);
mainGame->cbAttribute->setEnabled(false);
mainGame->cbRace->setEnabled(false);
mainGame->ebAttack->setEnabled(false);
mainGame->ebDefense->setEnabled(false);
mainGame->ebStar->setEnabled(false);
mainGame->ebScale->setEnabled(false);
mainGame->deckBuilder.filter_effect = 0;
mainGame->deckBuilder.result_string[0] = L'0';
mainGame->deckBuilder.result_string[1] = 0;
mainGame->deckBuilder.results.clear();
mainGame->deckBuilder.is_draging = false;
mainGame->deckBuilder.is_deleting = false;
mainGame->deckBuilder.is_clearing = false;
mainGame->device->setEventReceiver(&mainGame->deckBuilder);
for(int i = 0; i < 32; ++i)
mainGame->chkCategory[i]->setChecked(false);
mainGame->deckBuilder.Initialize();
break;
}
}
......
......@@ -15,7 +15,7 @@ struct HostInfo {
unsigned int lflist;
unsigned char rule;
unsigned char mode;
bool enable_priority;
unsigned char duel_rule;
bool no_check_deck;
bool no_shuffle_deck;
unsigned int start_lp;
......
......@@ -80,6 +80,8 @@ int ReplayMode::ReplayThread(void* param) {
int start_hand = cur_replay.ReadInt32();
int draw_count = cur_replay.ReadInt32();
int opt = cur_replay.ReadInt32();
int duel_rule = opt >> 16;
mainGame->dInfo.duel_rule = duel_rule;
set_player_info(pduel, 0, start_lp, start_hand, draw_count);
set_player_info(pduel, 1, start_lp, start_hand, draw_count);
mainGame->dInfo.lp[0] = start_lp;
......@@ -743,6 +745,15 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
DuelClient::ClientAnalyze(offset, pbuf - offset);
break;
}
case MSG_ROCK_PAPER_SCISSORS: {
player = BufferIO::ReadInt8(pbuf);
return ReadReplayResponse();
}
case MSG_HAND_RES: {
pbuf += 1;
DuelClient::ClientAnalyze(offset, pbuf - offset);
break;
}
case MSG_ANNOUNCE_RACE: {
player = BufferIO::ReadInt8(pbuf);
pbuf += 5;
......@@ -811,7 +822,7 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
return true;
}
void ReplayMode::ReplayRefresh(int flag) {
unsigned char queryBuffer[0x2000];
unsigned char queryBuffer[0x4000];
/*int len = */query_field_card(pduel, 0, LOCATION_MZONE, flag, queryBuffer, 0);
mainGame->dField.UpdateFieldCard(mainGame->LocalPlayer(0), LOCATION_MZONE, (char*)queryBuffer);
/*len = */query_field_card(pduel, 1, LOCATION_MZONE, flag, queryBuffer, 0);
......@@ -846,7 +857,7 @@ void ReplayMode::ReplayRefreshExtra(int player, int flag) {
mainGame->dField.UpdateFieldCard(mainGame->LocalPlayer(player), LOCATION_EXTRA, (char*)queryBuffer);
}
void ReplayMode::ReplayRefreshSingle(int player, int location, int sequence, int flag) {
unsigned char queryBuffer[0x2000];
unsigned char queryBuffer[0x4000];
/*int len = */query_card(pduel, player, location, sequence, flag, queryBuffer, 0);
mainGame->dField.UpdateCard(mainGame->LocalPlayer(player), location, sequence, (char*)queryBuffer);
}
......@@ -855,17 +866,7 @@ int ReplayMode::MessageHandler(long fduel, int type) {
return 0;
char msgbuf[1024];
get_log_message(fduel, (byte*)msgbuf);
if(enable_log == 1) {
wchar_t wbuf[1024];
BufferIO::DecodeUTF8(msgbuf, wbuf);
mainGame->AddChatMsg(wbuf, 9);
} else if(enable_log == 2) {
FILE* fp = fopen("error.log", "at");
if(!fp)
return 0;
fprintf(fp, "[Script error:] %s\n", msgbuf);
fclose(fp);
}
mainGame->AddDebugMsg(msgbuf);
return 0;
}
......
......@@ -37,12 +37,12 @@ public:
static void Undo();
static bool ReplayAnalyze(char* msg, unsigned int len);
static void ReplayRefresh(int flag = 0x781fff);
static void ReplayRefresh(int flag = 0xf81fff);
static void ReplayRefreshHand(int player, int flag = 0x781fff);
static void ReplayRefreshGrave(int player, int flag = 0x181fff);
static void ReplayRefreshDeck(int player, int flag = 0x181fff);
static void ReplayRefreshExtra(int player, int flag = 0x181fff);
static void ReplayRefreshSingle(int player, int location, int sequence, int flag = 0x781fff);
static void ReplayRefreshSingle(int player, int location, int sequence, int flag = 0xf81fff);
static int MessageHandler(long fduel, int type);
};
......
......@@ -412,9 +412,7 @@ void SingleDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
pduel = create_duel(rnd.rand());
set_player_info(pduel, 0, host_info.start_lp, host_info.start_hand, host_info.draw_count);
set_player_info(pduel, 1, host_info.start_lp, host_info.start_hand, host_info.draw_count);
int opt = 0;
if(host_info.enable_priority)
opt |= DUEL_OBSOLETE_RULING;
int opt = (int)host_info.duel_rule << 16;
if(host_info.no_shuffle_deck)
opt |= DUEL_PSEUDO_SHUFFLE;
last_replay.WriteInt32(host_info.start_lp, false);
......@@ -1252,6 +1250,20 @@ int SingleDuel::Analyze(char* msgbuffer, unsigned int len) {
NetServer::ReSendToPlayer(*oit);
break;
}
case MSG_ROCK_PAPER_SCISSORS: {
player = BufferIO::ReadInt8(pbuf);
WaitforResponse(player);
NetServer::SendBufferToPlayer(players[player], STOC_GAME_MSG, offset, pbuf - offset);
return 1;
}
case MSG_HAND_RES: {
pbuf += 1;
NetServer::SendBufferToPlayer(players[0], STOC_GAME_MSG, offset, pbuf - offset);
NetServer::ReSendToPlayer(players[1]);
for (auto oit = observers.begin(); oit != observers.end(); ++oit)
NetServer::ReSendToPlayer(*oit);
break;
}
case MSG_ANNOUNCE_RACE: {
player = BufferIO::ReadInt8(pbuf);
pbuf += 5;
......@@ -1476,17 +1488,7 @@ int SingleDuel::MessageHandler(long fduel, int type) {
return 0;
char msgbuf[1024];
get_log_message(fduel, (byte*)msgbuf);
if(enable_log == 1) {
wchar_t wbuf[1024];
BufferIO::DecodeUTF8(msgbuf, wbuf);
mainGame->AddChatMsg(wbuf, 9);
} else if(enable_log == 2) {
FILE* fp = fopen("error.log", "at");
if(!fp)
return 0;
fprintf(fp, "[Script error:] %s\n", msgbuf);
fclose(fp);
}
mainGame->AddDebugMsg(msgbuf);
return 0;
}
void SingleDuel::SingleTimer(evutil_socket_t fd, short events, void* arg) {
......
......@@ -31,12 +31,12 @@ public:
void DuelEndProc();
void WaitforResponse(int playerid);
void RefreshMzone(int player, int flag = 0x81fff, int use_cache = 1);
void RefreshMzone(int player, int flag = 0x881fff, int use_cache = 1);
void RefreshSzone(int player, int flag = 0x681fff, int use_cache = 1);
void RefreshHand(int player, int flag = 0x781fff, int use_cache = 1);
void RefreshGrave(int player, int flag = 0x81fff, int use_cache = 1);
void RefreshExtra(int player, int flag = 0x81fff, int use_cache = 1);
void RefreshSingle(int player, int location, int sequence, int flag = 0x781fff);
void RefreshSingle(int player, int location, int sequence, int flag = 0xf81fff);
static int MessageHandler(long fduel, int type);
static void SingleTimer(evutil_socket_t fd, short events, void* arg);
......
This diff is collapsed.
......@@ -21,12 +21,12 @@ public:
static int SinglePlayThread(void* param);
static bool SinglePlayAnalyze(char* msg, unsigned int len);
static void SinglePlayRefresh(int flag = 0x781fff);
static void SinglePlayRefresh(int flag = 0xf81fff);
static void SinglePlayRefreshHand(int player, int flag = 0x781fff);
static void SinglePlayRefreshGrave(int player, int flag = 0x181fff);
static void SinglePlayRefreshDeck(int player, int flag = 0x181fff);
static void SinglePlayRefreshExtra(int player, int flag = 0x181fff);
static void SinglePlayRefreshSingle(int player, int location, int sequence, int flag = 0x781fff);
static void SinglePlayRefreshSingle(int player, int location, int sequence, int flag = 0xf81fff);
static void SinglePlayReload();
static byte* ScriptReader(const char* script_name, int* slen);
......
......@@ -382,9 +382,7 @@ void TagDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
pduel = create_duel(rnd.rand());
set_player_info(pduel, 0, host_info.start_lp, host_info.start_hand, host_info.draw_count);
set_player_info(pduel, 1, host_info.start_lp, host_info.start_hand, host_info.draw_count);
int opt = 0;
if(host_info.enable_priority)
opt |= DUEL_OBSOLETE_RULING;
int opt = (int)host_info.duel_rule << 16;
if(host_info.no_shuffle_deck)
opt |= DUEL_PSEUDO_SHUFFLE;
opt |= DUEL_TAG_MODE;
......@@ -1291,6 +1289,22 @@ int TagDuel::Analyze(char* msgbuffer, unsigned int len) {
NetServer::ReSendToPlayer(*oit);
break;
}
case MSG_ROCK_PAPER_SCISSORS: {
player = BufferIO::ReadInt8(pbuf);
WaitforResponse(player);
NetServer::SendBufferToPlayer(players[player], STOC_GAME_MSG, offset, pbuf - offset);
return 1;
}
case MSG_HAND_RES: {
pbuf += 1;
NetServer::SendBufferToPlayer(players[0], STOC_GAME_MSG, offset, pbuf - offset);
NetServer::ReSendToPlayer(players[1]);
NetServer::ReSendToPlayer(players[2]);
NetServer::ReSendToPlayer(players[3]);
for (auto oit = observers.begin(); oit != observers.end(); ++oit)
NetServer::ReSendToPlayer(*oit);
break;
}
case MSG_ANNOUNCE_RACE: {
player = BufferIO::ReadInt8(pbuf);
pbuf += 5;
......@@ -1583,17 +1597,7 @@ int TagDuel::MessageHandler(long fduel, int type) {
return 0;
char msgbuf[1024];
get_log_message(fduel, (byte*)msgbuf);
if(enable_log == 1) {
wchar_t wbuf[1024];
BufferIO::DecodeUTF8(msgbuf, wbuf);
mainGame->AddChatMsg(wbuf, 9);
} else if(enable_log == 2) {
FILE* fp = fopen("error.log", "at");
if(!fp)
return 0;
fprintf(fp, "[Script error:] %s\n", msgbuf);
fclose(fp);
}
mainGame->AddDebugMsg(msgbuf);
return 0;
}
void TagDuel::TagTimer(evutil_socket_t fd, short events, void* arg) {
......
......@@ -31,12 +31,12 @@ public:
void DuelEndProc();
void WaitforResponse(int playerid);
void RefreshMzone(int player, int flag = 0x81fff, int use_cache = 1);
void RefreshMzone(int player, int flag = 0x881fff, int use_cache = 1);
void RefreshSzone(int player, int flag = 0x681fff, int use_cache = 1);
void RefreshHand(int player, int flag = 0x781fff, int use_cache = 1);
void RefreshGrave(int player, int flag = 0x81fff, int use_cache = 1);
void RefreshExtra(int player, int flag = 0x81fff, int use_cache = 1);
void RefreshSingle(int player, int location, int sequence, int flag = 0x781fff);
void RefreshSingle(int player, int location, int sequence, int flag = 0xf81fff);
static int MessageHandler(long fduel, int type);
static void TagTimer(evutil_socket_t fd, short events, void* arg);
......
This diff is collapsed.
Subproject commit 8f6052181238b2e544ca36b970582a6963ce36f4
Subproject commit 45f3eb3d39e53bd7b8861aa12b7857e667fb9c51
Subproject commit 5bac33f528c7838f1909fd4e460d1b9d5308bdf8
Subproject commit 1a2e492ed3ab40c74cb849af2bf19ad807681fc4
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment