Commit 1b2575eb authored by nanahira's avatar nanahira

update

parent be33fbeb
No preview for this file type
--SPYRAL-ザ・ダブルヘリックス
--SPYRAL - The Double Helix
--Script by nekrozar
function c1322368.initial_effect(c)
--link summon
c:EnableReviveLimit()
aux.AddLinkProcedure(c,aux.FilterBoolFunction(Card.IsSetCard,0xee),2,2)
--change name
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e1:SetCode(EFFECT_CHANGE_CODE)
e1:SetRange(LOCATION_MZONE+LOCATION_GRAVE)
e1:SetValue(41091257)
c:RegisterEffect(e1)
--special summon
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(1322368,0))
e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
e2:SetType(EFFECT_TYPE_IGNITION)
e2:SetRange(LOCATION_MZONE)
e2:SetCountLimit(1,1322368)
e2:SetTarget(c1322368.sptg)
e2:SetOperation(c1322368.spop)
c:RegisterEffect(e2)
end
function c1322368.spfilter(c,e,tp,zone)
return c:IsSetCard(0xee) and c:IsType(TYPE_MONSTER) and (c:IsAbleToHand() or (zone~=0 and c:IsCanBeSpecialSummoned(e,0,tp,false,false,POS_FACEUP,tp,zone)))
end
function c1322368.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
local zone=e:GetHandler():GetLinkedZone()
if chk==0 then return Duel.GetFieldGroupCount(tp,0,LOCATION_DECK)>0
and Duel.IsExistingMatchingCard(c1322368.spfilter,tp,LOCATION_DECK+LOCATION_GRAVE,0,1,nil,e,tp,zone) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_CARDTYPE)
e:SetLabel(Duel.SelectOption(tp,70,71,72))
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_DECK+LOCATION_GRAVE)
end
function c1322368.spop(e,tp,eg,ep,ev,re,r,rp)
if Duel.GetFieldGroupCount(tp,0,LOCATION_DECK)==0 then return end
Duel.ConfirmDecktop(1-tp,1)
local g=Duel.GetDecktopGroup(1-tp,1)
local tc=g:GetFirst()
local opt=e:GetLabel()
if (opt==0 and tc:IsType(TYPE_MONSTER)) or (opt==1 and tc:IsType(TYPE_SPELL)) or (opt==2 and tc:IsType(TYPE_TRAP)) then
local zone=e:GetHandler():GetLinkedZone()
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local sg=Duel.SelectMatchingCard(tp,aux.NecroValleyFilter(c1322368.spfilter),tp,LOCATION_DECK+LOCATION_GRAVE,0,1,1,nil,e,tp,zone)
local sc=sg:GetFirst()
if sc then
if zone~=0 and sc:IsCanBeSpecialSummoned(e,0,tp,false,false,POS_FACEUP,tp,zone)
and (not sc:IsAbleToHand() or Duel.SelectYesNo(tp,aux.Stringid(1322368,1))) then
Duel.SpecialSummon(sc,0,tp,tp,false,false,POS_FACEUP,zone)
else
Duel.SendtoHand(sc,nil,REASON_EFFECT)
Duel.ConfirmCards(1-tp,sc)
end
end
end
end
--コード・トーカー
--Code Talker
--Scripted by Eerie Code
function c53413628.initial_effect(c)
--link summon
aux.AddLinkProcedure(c,aux.FilterBoolFunction(Card.IsLinkType,TYPE_EFFECT),2,2)
c:EnableReviveLimit()
--atk
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_UPDATE_ATTACK)
e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e1:SetRange(LOCATION_MZONE)
e1:SetValue(c53413628.atkval)
c:RegisterEffect(e1)
--indes
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e2:SetRange(LOCATION_MZONE)
e2:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
e2:SetCondition(c53413628.incon)
e2:SetValue(1)
c:RegisterEffect(e2)
local e3=e2:Clone()
e3:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
e3:SetValue(c53413628.inval)
c:RegisterEffect(e3)
end
function c53413628.atkval(e,c)
return c:GetLinkedGroupCount()*500
end
function c53413628.incon(e)
return e:GetHandler():GetLinkedGroupCount()>0
end
function c53413628.inval(e,re,r,rp)
return rp~=e:GetHandlerPlayer()
end
--サブテラーマリスの妖魔
--Subterror Behemoth Apparition
--Script by nekrozar
function c74937659.initial_effect(c)
--link summon
c:EnableReviveLimit()
aux.AddLinkProcedure(c,aux.FilterBoolFunction(Card.IsLinkType,TYPE_FLIP),2,2)
--atkup
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_MATERIAL_CHECK)
e1:SetValue(c74937659.matcheck)
c:RegisterEffect(e1)
--to grave
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(74937659,0))
e2:SetCategory(CATEGORY_TOGRAVE+CATEGORY_SPECIAL_SUMMON)
e2:SetType(EFFECT_TYPE_IGNITION)
e2:SetCountLimit(1,74937659)
e2:SetRange(LOCATION_MZONE)
e2:SetTarget(c74937659.tgtg)
e2:SetOperation(c74937659.tgop)
c:RegisterEffect(e2)
--search
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(74937659,1))
e3:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH)
e3:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_F)
e3:SetCode(EVENT_FLIP)
e3:SetRange(LOCATION_MZONE)
e3:SetCountLimit(1)
e3:SetCondition(c74937659.thcon)
e3:SetTarget(c74937659.thtg)
e3:SetOperation(c74937659.thop)
c:RegisterEffect(e3)
end
function c74937659.matfilter(c)
return c:IsSetCard(0xed) and c:GetOriginalLevel()>=0
end
function c74937659.matcheck(e,c)
local g=c:GetMaterial():Filter(c74937659.matfilter,nil)
local atk=g:GetSum(Card.GetOriginalLevel)
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_UPDATE_ATTACK)
e1:SetValue(atk*100)
e1:SetReset(RESET_EVENT+0xff0000)
c:RegisterEffect(e1)
end
function c74937659.tgfilter(c)
return c:IsType(TYPE_FLIP) and c:IsAbleToGrave()
end
function c74937659.spfilter(c,e,tp,zone)
return c:IsCanBeSpecialSummoned(e,0,tp,false,false,POS_FACEDOWN_DEFENSE,tp,zone)
end
function c74937659.tgtg(e,tp,eg,ep,ev,re,r,rp,chk)
local zone=e:GetHandler():GetLinkedZone()
if chk==0 then return Duel.IsExistingMatchingCard(c74937659.tgfilter,tp,LOCATION_DECK,0,1,nil)
and Duel.IsExistingMatchingCard(c74937659.spfilter,tp,LOCATION_HAND,0,1,nil,e,tp,zone) end
Duel.SetOperationInfo(0,CATEGORY_TOGRAVE,nil,1,tp,LOCATION_DECK)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_HAND)
end
function c74937659.tgop(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE)
local g=Duel.SelectMatchingCard(tp,c74937659.tgfilter,tp,LOCATION_DECK,0,1,1,nil)
if g:GetCount()>0 and Duel.SendtoGrave(g,REASON_EFFECT)~=0
and g:GetFirst():IsLocation(LOCATION_GRAVE) then
local zone=e:GetHandler():GetLinkedZone()
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local sg=Duel.SelectMatchingCard(tp,c74937659.spfilter,tp,LOCATION_HAND,0,1,1,nil,e,tp,zone)
if zone~=0 and sg:GetCount()>0 then
Duel.SpecialSummon(sg,0,tp,tp,false,false,POS_FACEDOWN_DEFENSE,zone)
Duel.ConfirmCards(1-tp,sg)
end
end
end
function c74937659.cfilter(c,g)
return g:IsContains(c)
end
function c74937659.thcon(e,tp,eg,ep,ev,re,r,rp)
local lg=e:GetHandler():GetLinkedGroup()
return lg and eg:IsExists(c74937659.cfilter,1,nil,lg)
end
function c74937659.thfilter(c)
return c:IsType(TYPE_FLIP) and c:IsAbleToHand()
end
function c74937659.thtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK+LOCATION_GRAVE)
end
function c74937659.thop(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
local g=Duel.SelectMatchingCard(tp,aux.NecroValleyFilter(c74937659.thfilter),tp,LOCATION_DECK+LOCATION_GRAVE,0,1,1,nil)
if g:GetCount()>0 then
Duel.SendtoHand(g,nil,REASON_EFFECT)
Duel.ConfirmCards(1-tp,g)
end
end
......@@ -216,6 +216,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
if(mainGame->chkCategory[i]->isChecked())
filter_effect |= filter;
mainGame->HideElement(mainGame->wCategories);
InstantSearch();
break;
}
case BUTTON_SIDE_OK: {
......@@ -308,6 +309,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
if (mainGame->btnMark[7]->isPressed())
filter_marks |= 0004;
mainGame->HideElement(mainGame->wLinkMarks);
InstantSearch();
break;
}
}
......@@ -328,8 +330,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
case irr::gui::EGET_EDITBOX_CHANGED: {
switch(id) {
case EDITBOX_KEYWORD: {
if(mainGame->gameConf.auto_search_limit >= 0 && (wcslen(mainGame->ebCardName->getText()) >= mainGame->gameConf.auto_search_limit))
StartFilter();
InstantSearch();
break;
}
}
......@@ -446,6 +447,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
break;
}
}
InstantSearch();
break;
}
case COMBOBOX_SORTTYPE: {
......@@ -462,8 +464,13 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
mainGame->ebDefense->setEnabled(true);
}
}
InstantSearch();
break;
}
case COMBOBOX_ATTRIBUTE:
case COMBOBOX_RACE:
case COMBOBOX_LIMIT:
InstantSearch();
}
}
default: break;
......@@ -854,6 +861,10 @@ void DeckBuilder::FilterCards() {
}
SortList();
}
void DeckBuilder::InstantSearch() {
if(mainGame->gameConf.auto_search_limit >= 0 && (wcslen(mainGame->ebCardName->getText()) >= mainGame->gameConf.auto_search_limit))
StartFilter();
}
void DeckBuilder::ClearSearch() {
mainGame->cbCardType->setSelected(0);
mainGame->cbCardType2->setSelected(0);
......
......@@ -17,6 +17,7 @@ public:
void FilterCards();
void StartFilter();
void ClearFilter();
void InstantSearch();
void ClearSearch();
void SortList();
......
......@@ -746,10 +746,10 @@ void Game::DrawSpec() {
switch(showcard) {
case 1: {
driver->draw2DImage(imageManager.GetTexture(showcardcode), position2di(574, 150));
driver->draw2DImage(imageManager.tMask, recti(574, 150, 574 + (showcarddif > 177 ? 177 : showcarddif), 404),
recti(254 - showcarddif, 0, 254 - (showcarddif > 177 ? showcarddif - 177 : 0), 254), 0, 0, true);
driver->draw2DImage(imageManager.tMask, recti(574, 150, 574 + (showcarddif > CARD_IMG_WIDTH ? CARD_IMG_WIDTH : showcarddif), 404),
recti(CARD_IMG_HEIGHT - showcarddif, 0, CARD_IMG_HEIGHT - (showcarddif > CARD_IMG_WIDTH ? showcarddif - CARD_IMG_WIDTH : 0), CARD_IMG_HEIGHT), 0, 0, true);
showcarddif += 15;
if(showcarddif >= 254) {
if(showcarddif >= CARD_IMG_HEIGHT) {
showcard = 2;
showcarddif = 0;
}
......@@ -757,9 +757,9 @@ void Game::DrawSpec() {
}
case 2: {
driver->draw2DImage(imageManager.GetTexture(showcardcode), position2di(574, 150));
driver->draw2DImage(imageManager.tMask, recti(574 + showcarddif, 150, 761, 404), recti(0, 0, 177 - showcarddif, 254), 0, 0, true);
driver->draw2DImage(imageManager.tMask, recti(574 + showcarddif, 150, 761, 404), recti(0, 0, CARD_IMG_WIDTH - showcarddif, CARD_IMG_HEIGHT), 0, 0, true);
showcarddif += 15;
if(showcarddif >= 177) {
if(showcarddif >= CARD_IMG_WIDTH) {
showcard = 0;
}
break;
......@@ -777,7 +777,7 @@ void Game::DrawSpec() {
matManager.c2d[2] = (showcarddif << 24) | 0xffffff;
matManager.c2d[3] = (showcarddif << 24) | 0xffffff;
driver->draw2DImage(imageManager.GetTexture(showcardcode), recti(574, 154, 751, 404),
recti(0, 0, 177, 254), 0, matManager.c2d, true);
recti(0, 0, CARD_IMG_WIDTH, CARD_IMG_HEIGHT), 0, matManager.c2d, true);
if(showcarddif < 255)
showcarddif += 17;
break;
......@@ -788,7 +788,7 @@ void Game::DrawSpec() {
matManager.c2d[2] = (showcarddif << 25) | 0xffffff;
matManager.c2d[3] = (showcarddif << 25) | 0xffffff;
driver->draw2DImage(imageManager.GetTexture(showcardcode), recti(662 - showcarddif * 0.69685f, 277 - showcarddif, 662 + showcarddif * 0.69685f, 277 + showcarddif),
recti(0, 0, 177, 254), 0, matManager.c2d, true);
recti(0, 0, CARD_IMG_WIDTH, CARD_IMG_HEIGHT), 0, matManager.c2d, true);
if(showcarddif < 127)
showcarddif += 9;
break;
......@@ -803,12 +803,12 @@ void Game::DrawSpec() {
}
case 7: {
core::position2d<s32> corner[4];
float y = sin(showcarddif * 3.1415926f / 180.0f) * 254;
corner[0] = core::position2d<s32>(574 - (254 - y) * 0.3f, 404 - y);
corner[1] = core::position2d<s32>(751 + (254 - y) * 0.3f, 404 - y);
float y = sin(showcarddif * 3.1415926f / 180.0f) * CARD_IMG_HEIGHT;
corner[0] = core::position2d<s32>(574 - (CARD_IMG_HEIGHT - y) * 0.3f, 404 - y);
corner[1] = core::position2d<s32>(751 + (CARD_IMG_HEIGHT - y) * 0.3f, 404 - y);
corner[2] = core::position2d<s32>(574, 404);
corner[3] = core::position2d<s32>(751, 404);
irr::gui::Draw2DImageQuad(driver, imageManager.GetTexture(showcardcode), rect<s32>(0, 0, 177, 254), corner);
irr::gui::Draw2DImageQuad(driver, imageManager.GetTexture(showcardcode), rect<s32>(0, 0, CARD_IMG_WIDTH, CARD_IMG_HEIGHT), corner);
showcardp++;
showcarddif += 9;
if(showcarddif >= 90)
......@@ -1022,8 +1022,6 @@ void Game::WaitFrameSignal(int frame) {
frameSignal.Wait();
}
void Game::DrawThumb(code_pointer cp, position2di pos, std::unordered_map<int, int>* lflist) {
const int width = 44; //standard pic size, maybe it should be defined in game.h
const int height = 64;
int code = cp->first;
int lcode = cp->second.alias;
if(lcode == 0)
......@@ -1032,7 +1030,7 @@ void Game::DrawThumb(code_pointer cp, position2di pos, std::unordered_map<int, i
if(img == NULL)
return; //NULL->getSize() will cause a crash
dimension2d<u32> size = img->getOriginalSize();
driver->draw2DImage(img, rect<s32>(pos.X, pos.Y, pos.X + width, pos.Y + height), rect<s32>(0, 0, size.Width, size.Height));
driver->draw2DImage(img, rect<s32>(pos.X, pos.Y, pos.X + CARD_THUMB_WIDTH, pos.Y + CARD_THUMB_HEIGHT), rect<s32>(0, 0, size.Width, size.Height));
if(lflist->count(lcode)) {
switch((*lflist)[lcode]) {
......
......@@ -282,6 +282,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->wDeckEdit->setVisible(false);
mainGame->wFilter->setVisible(false);
mainGame->wSort->setVisible(false);
mainGame->stTip->setVisible(false);
mainGame->btnSideOK->setVisible(true);
if(mainGame->dInfo.player_type < 7)
mainGame->btnLeaveGame->setVisible(false);
......
......@@ -227,10 +227,10 @@ bool Game::Initialize() {
btnHostPrepStart = env->addButton(rect<s32>(230, 280, 340, 305), wHostPrepare, BUTTON_HP_START, dataManager.GetSysString(1215));
btnHostPrepCancel = env->addButton(rect<s32>(350, 280, 460, 305), wHostPrepare, BUTTON_HP_CANCEL, dataManager.GetSysString(1210));
//img
wCardImg = env->addStaticText(L"", rect<s32>(1, 1, 199, 273), true, false, 0, -1, true);
wCardImg = env->addStaticText(L"", rect<s32>(1, 1, 1 + CARD_IMG_WIDTH + 20, 1 + CARD_IMG_HEIGHT + 18), true, false, 0, -1, true);
wCardImg->setBackgroundColor(0xc0c0c0c0);
wCardImg->setVisible(false);
imgCard = env->addImage(rect<s32>(10, 9, 187, 263), wCardImg);
imgCard = env->addImage(rect<s32>(10, 9, 10 + CARD_IMG_WIDTH, 9 + CARD_IMG_HEIGHT), wCardImg);
imgCard->setImage(imageManager.tCover[0]);
imgCard->setUseAlphaChannel(true);
//phase
......@@ -364,14 +364,14 @@ bool Game::Initialize() {
btnPSAU->setImageScale(core::vector2df(0.5, 0.5));
btnPSAD = irr::gui::CGUIImageButton::addImageButton(env, rect<s32>(155, 45, 295, 185), wPosSelect, BUTTON_POS_AD);
btnPSAD->setImageScale(core::vector2df(0.5, 0.5));
btnPSAD->setImage(imageManager.tCover[0], rect<s32>(0, 0, 177, 254));
btnPSAD->setImage(imageManager.tCover[0], rect<s32>(0, 0, CARD_IMG_WIDTH, CARD_IMG_HEIGHT));
btnPSDU = irr::gui::CGUIImageButton::addImageButton(env, rect<s32>(300, 45, 440, 185), wPosSelect, BUTTON_POS_DU);
btnPSDU->setImageScale(core::vector2df(0.5, 0.5));
btnPSDU->setImageRotation(270);
btnPSDD = irr::gui::CGUIImageButton::addImageButton(env, rect<s32>(445, 45, 585, 185), wPosSelect, BUTTON_POS_DD);
btnPSDD->setImageScale(core::vector2df(0.5, 0.5));
btnPSDD->setImageRotation(270);
btnPSDD->setImage(imageManager.tCover[0], rect<s32>(0, 0, 177, 254));
btnPSDD->setImage(imageManager.tCover[0], rect<s32>(0, 0, CARD_IMG_WIDTH, CARD_IMG_HEIGHT));
//card select
wCardSelect = env->addWindow(rect<s32>(320, 100, 1000, 400), false, L"");
wCardSelect->getCloseButton()->setVisible(false);
......@@ -493,7 +493,7 @@ bool Game::Initialize() {
cbCardType2->setMaxSelectionRows(10);
cbCardType2->addItem(dataManager.GetSysString(1310), 0);
env->addStaticText(dataManager.GetSysString(1315), rect<s32>(205, 2 + 25 / 6, 280, 22 + 25 / 6), false, false, wFilter);
cbLimit = env->addComboBox(rect<s32>(260, 25 / 6, 390, 20 + 25 / 6), wFilter, -1);
cbLimit = env->addComboBox(rect<s32>(260, 25 / 6, 390, 20 + 25 / 6), wFilter, COMBOBOX_LIMIT);
cbLimit->setMaxSelectionRows(10);
cbLimit->addItem(dataManager.GetSysString(1310));
cbLimit->addItem(dataManager.GetSysString(1316));
......@@ -504,13 +504,13 @@ bool Game::Initialize() {
cbLimit->addItem(dataManager.GetSysString(1242));
cbLimit->addItem(dataManager.GetSysString(1243));
env->addStaticText(dataManager.GetSysString(1319), rect<s32>(10, 22 + 50 / 6, 70, 42 + 50 / 6), false, false, wFilter);
cbAttribute = env->addComboBox(rect<s32>(60, 20 + 50 / 6, 190, 40 + 50 / 6), wFilter, -1);
cbAttribute = env->addComboBox(rect<s32>(60, 20 + 50 / 6, 190, 40 + 50 / 6), wFilter, COMBOBOX_ATTRIBUTE);
cbAttribute->setMaxSelectionRows(10);
cbAttribute->addItem(dataManager.GetSysString(1310), 0);
for(int filter = 0x1; filter != 0x80; filter <<= 1)
cbAttribute->addItem(dataManager.FormatAttribute(filter), filter);
env->addStaticText(dataManager.GetSysString(1321), rect<s32>(10, 42 + 75 / 6, 70, 62 + 75 / 6), false, false, wFilter);
cbRace = env->addComboBox(rect<s32>(60, 40 + 75 / 6, 190, 60 + 75 / 6), wFilter, -1);
cbRace = env->addComboBox(rect<s32>(60, 40 + 75 / 6, 190, 60 + 75 / 6), wFilter, COMBOBOX_RACE);
cbRace->setMaxSelectionRows(10);
cbRace->addItem(dataManager.GetSysString(1310), 0);
for(int filter = 0x1; filter != 0x2000000; filter <<= 1)
......@@ -933,6 +933,8 @@ void Game::LoadConfig() {
char strbuf[32];
char valbuf[256];
wchar_t wstr[256];
gameConf.use_d3d = 0;
gameConf.use_image_scale = 1;
gameConf.antialias = 0;
gameConf.serverport = 7911;
gameConf.textfontsize = 12;
......@@ -965,6 +967,8 @@ void Game::LoadConfig() {
gameConf.antialias = atoi(valbuf);
} else if(!strcmp(strbuf, "use_d3d")) {
gameConf.use_d3d = atoi(valbuf) > 0;
} else if(!strcmp(strbuf, "use_image_scale")) {
gameConf.use_image_scale = atoi(valbuf) > 0;
} else if(!strcmp(strbuf, "errorlog")) {
enable_log = atoi(valbuf);
} else if(!strcmp(strbuf, "textfont")) {
......@@ -1037,6 +1041,7 @@ void Game::SaveConfig() {
fprintf(fp, "#config file\n#nickname & gamename should be less than 20 characters\n");
char linebuf[256];
fprintf(fp, "use_d3d = %d\n", gameConf.use_d3d ? 1 : 0);
fprintf(fp, "use_image_scale = %d\n", gameConf.use_image_scale ? 1 : 0);
fprintf(fp, "antialias = %d\n", gameConf.antialias);
fprintf(fp, "errorlog = %d\n", enable_log);
BufferIO::CopyWStr(ebNickName->getText(), gameConf.nickname, 20);
......
......@@ -18,6 +18,7 @@ namespace ygo {
#ifndef YGOPRO_SERVER_MODE
struct Config {
bool use_d3d;
bool use_image_scale;
unsigned short antialias;
unsigned short serverport;
unsigned char textfontsize;
......@@ -446,6 +447,11 @@ extern HostInfo game_info;
}
#define CARD_IMG_WIDTH 177
#define CARD_IMG_HEIGHT 254
#define CARD_THUMB_WIDTH 44
#define CARD_THUMB_HEIGHT 64
#define UEVENT_EXIT 0x1
#define UEVENT_TOWINDOW 0x2
......@@ -562,6 +568,8 @@ extern HostInfo game_info;
#define SCROLL_FILTER 315
#define EDITBOX_KEYWORD 316
#define BUTTON_CLEAR_FILTER 317
#define COMBOBOX_ATTRIBUTE 318
#define COMBOBOX_RACE 319
#define BUTTON_REPLAY_START 320
#define BUTTON_REPLAY_PAUSE 321
#define BUTTON_REPLAY_STEP 322
......@@ -575,6 +583,7 @@ extern HostInfo game_info;
#define BUTTON_CANCEL_SINGLEPLAY 352
#define CHECKBOX_AUTO_SEARCH 360
#define COMBOBOX_SORTTYPE 370
#define COMBOBOX_LIMIT 371
#define BUTTON_MARKS_FILTER 380
#define BUTTON_MARKERS_OK 381
......
#include "image_manager.h"
#include "game.h"
namespace ygo {
......@@ -63,6 +64,100 @@ void ImageManager::RemoveTexture(int code) {
tMap.erase(tit);
}
}
// function by Warr1024, from https://github.com/minetest/minetest/issues/2419 , modified
void imageScaleNNAA(irr::video::IImage *src, irr::video::IImage *dest)
{
double sx, sy, minsx, maxsx, minsy, maxsy, area, ra, ga, ba, aa, pw, ph, pa;
u32 dy, dx;
irr::video::SColor pxl;
// Cache rectsngle boundaries.
double sw = src->getDimension().Width * 1.0;
double sh = src->getDimension().Height * 1.0;
// Walk each destination image pixel.
// Note: loop y around x for better cache locality.
irr::core::dimension2d<u32> dim = dest->getDimension();
for(dy = 0; dy < dim.Height; dy++)
for(dx = 0; dx < dim.Width; dx++) {
// Calculate floating-point source rectangle bounds.
minsx = dx * sw / dim.Width;
maxsx = minsx + sw / dim.Width;
minsy = dy * sh / dim.Height;
maxsy = minsy + sh / dim.Height;
// Total area, and integral of r, g, b values over that area,
// initialized to zero, to be summed up in next loops.
area = 0;
ra = 0;
ga = 0;
ba = 0;
aa = 0;
// Loop over the integral pixel positions described by those bounds.
for(sy = floor(minsy); sy < maxsy; sy++)
for(sx = floor(minsx); sx < maxsx; sx++) {
// Calculate width, height, then area of dest pixel
// that's covered by this source pixel.
pw = 1;
if(minsx > sx)
pw += sx - minsx;
if(maxsx < (sx + 1))
pw += maxsx - sx - 1;
ph = 1;
if(minsy > sy)
ph += sy - minsy;
if(maxsy < (sy + 1))
ph += maxsy - sy - 1;
pa = pw * ph;
// Get source pixel and add it to totals, weighted
// by covered area and alpha.
pxl = src->getPixel((u32)sx, (u32)sy);
area += pa;
ra += pa * pxl.getRed();
ga += pa * pxl.getGreen();
ba += pa * pxl.getBlue();
aa += pa * pxl.getAlpha();
}
// Set the destination image pixel to the average color.
if(area > 0) {
pxl.setRed(ra / area + 0.5);
pxl.setGreen(ga / area + 0.5);
pxl.setBlue(ba / area + 0.5);
pxl.setAlpha(aa / area + 0.5);
} else {
pxl.setRed(0);
pxl.setGreen(0);
pxl.setBlue(0);
pxl.setAlpha(0);
}
dest->setPixel(dx, dy, pxl);
}
}
irr::video::ITexture* ImageManager::GetTextureFromFile(char* file, s32 width, s32 height) {
if(mainGame->gameConf.use_image_scale) {
irr::video::ITexture* texture;
irr::video::IImage* srcimg = driver->createImageFromFile(file);
if(srcimg == NULL)
return NULL;
if(srcimg->getDimension() == irr::core::dimension2d<u32>(width, height)) {
texture = driver->addTexture(file, srcimg);
} else {
video::IImage *destimg = driver->createImage(srcimg->getColorFormat(), irr::core::dimension2d<u32>(width, height));
imageScaleNNAA(srcimg, destimg);
texture = driver->addTexture(file, destimg);
destimg->drop();
}
srcimg->drop();
return texture;
} else {
return driver->getTexture(file);
}
}
irr::video::ITexture* ImageManager::GetTexture(int code) {
if(code == 0)
return tUnknown;
......@@ -70,23 +165,22 @@ irr::video::ITexture* ImageManager::GetTexture(int code) {
if(tit == tMap.end()) {
char file[256];
sprintf(file, "expansions/pics/%d.jpg", code);
irr::video::ITexture* img = driver->getTexture(file);
irr::video::ITexture* img = GetTextureFromFile(file, CARD_IMG_WIDTH, CARD_IMG_HEIGHT);
if(img == NULL) {
sprintf(file, "pics/%d.jpg", code);
img = driver->getTexture(file);
img = GetTextureFromFile(file, CARD_IMG_WIDTH, CARD_IMG_HEIGHT);
}
if(img == NULL) {
if(img == NULL && !mainGame->gameConf.use_image_scale) {
tMap[code] = NULL;
return GetTextureThumb(code);
} else {
tMap[code] = img;
return img;
}
tMap[code] = img;
return (img == NULL) ? tUnknown : img;
}
if(tit->second)
return tit->second;
else
return GetTextureThumb(code);
return mainGame->gameConf.use_image_scale ? tUnknown : GetTextureThumb(code);
}
irr::video::ITexture* ImageManager::GetTextureThumb(int code) {
if(code == 0)
......@@ -95,18 +189,21 @@ irr::video::ITexture* ImageManager::GetTextureThumb(int code) {
if(tit == tThumb.end()) {
char file[256];
sprintf(file, "expansions/pics/thumbnail/%d.jpg", code);
irr::video::ITexture* img = driver->getTexture(file);
irr::video::ITexture* img = GetTextureFromFile(file, CARD_THUMB_WIDTH, CARD_THUMB_HEIGHT);
if(img == NULL) {
sprintf(file, "pics/thumbnail/%d.jpg", code);
img = driver->getTexture(file);
img = GetTextureFromFile(file, CARD_THUMB_WIDTH, CARD_THUMB_HEIGHT);
}
if(img == NULL) {
tThumb[code] = NULL;
return tUnknown;
} else {
tThumb[code] = img;
return img;
if(img == NULL && mainGame->gameConf.use_image_scale) {
sprintf(file, "expansions/pics/%d.jpg", code);
img = GetTextureFromFile(file, CARD_THUMB_WIDTH, CARD_THUMB_HEIGHT);
if(img == NULL) {
sprintf(file, "pics/%d.jpg", code);
img = GetTextureFromFile(file, CARD_THUMB_WIDTH, CARD_THUMB_HEIGHT);
}
}
tThumb[code] = img;
return (img == NULL) ? tUnknown : img;
}
if(tit->second)
return tit->second;
......@@ -120,18 +217,18 @@ irr::video::ITexture* ImageManager::GetTextureField(int code) {
if(tit == tFields.end()) {
char file[256];
sprintf(file, "expansions/pics/field/%d.png", code);
irr::video::ITexture* img = driver->getTexture(file);
irr::video::ITexture* img = GetTextureFromFile(file, 512, 512);
if(img == NULL) {
sprintf(file, "expansions/pics/field/%d.jpg", code);
img = driver->getTexture(file);
img = GetTextureFromFile(file, 512, 512);
}
if(img == NULL) {
sprintf(file, "pics/field/%d.png", code);
img = driver->getTexture(file);
img = GetTextureFromFile(file, 512, 512);
}
if(img == NULL) {
sprintf(file, "pics/field/%d.jpg", code);
img = driver->getTexture(file);
img = GetTextureFromFile(file, 512, 512);
if(img == NULL) {
tFields[code] = NULL;
return NULL;
......
......@@ -13,6 +13,7 @@ public:
void SetDevice(irr::IrrlichtDevice* dev);
void ClearTexture();
void RemoveTexture(int code);
irr::video::ITexture* GetTextureFromFile(char* file, s32 width, s32 height);
irr::video::ITexture* GetTexture(int code);
irr::video::ITexture* GetTextureThumb(int code);
irr::video::ITexture* GetTextureField(int code);
......
......@@ -302,11 +302,11 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
myswprintf(infobuf, L"%d/%d/%d %02d:%02d:%02d\n", st->tm_year + 1900, st->tm_mon + 1, st->tm_mday, st->tm_hour, st->tm_min, st->tm_sec);
repinfo.append(infobuf);
wchar_t namebuf[4][20];
BufferIO::CopyWStr((unsigned short*)&ReplayMode::cur_replay.replay_data[0], namebuf[0], 20);
BufferIO::CopyWStr((unsigned short*)&ReplayMode::cur_replay.replay_data[40], namebuf[1], 20);
ReplayMode::cur_replay.ReadName(namebuf[0]);
ReplayMode::cur_replay.ReadName(namebuf[1]);
if(ReplayMode::cur_replay.pheader.flag & REPLAY_TAG) {
BufferIO::CopyWStr((unsigned short*)&ReplayMode::cur_replay.replay_data[80], namebuf[2], 20);
BufferIO::CopyWStr((unsigned short*)&ReplayMode::cur_replay.replay_data[120], namebuf[3], 20);
ReplayMode::cur_replay.ReadName(namebuf[2]);
ReplayMode::cur_replay.ReadName(namebuf[3]);
}
if(ReplayMode::cur_replay.pheader.flag & REPLAY_TAG)
myswprintf(infobuf, L"%ls\n%ls\n===VS===\n%ls\n%ls\n", namebuf[0], namebuf[1], namebuf[2], namebuf[3]);
......
......@@ -256,6 +256,13 @@ bool Replay::ReadNextResponse(unsigned char resp[64]) {
pdata += len;
return true;
}
void Replay::ReadName(wchar_t* data) {
if(!is_replaying)
return;
unsigned short buffer[20];
ReadData(buffer, 40);
BufferIO::CopyWStr(buffer, data, 20);
}
void Replay::ReadData(void* data, unsigned int length) {
if(!is_replaying)
return;
......
......@@ -36,6 +36,7 @@ public:
bool OpenReplay(const wchar_t* name);
static bool CheckReplay(const wchar_t* name);
bool ReadNextResponse(unsigned char resp[64]);
void ReadName(wchar_t* data);
void ReadHeader(ReplayHeader& header);
void ReadData(void* data, unsigned int length);
int ReadInt32();
......
......@@ -61,16 +61,16 @@ int ReplayMode::ReplayThread(void* param) {
int seed = rh.seed;
rnd.reset(seed);
if(rh.flag & REPLAY_TAG) {
cur_replay.ReadData(mainGame->dInfo.hostname, 40);
cur_replay.ReadData(mainGame->dInfo.hostname_tag, 40);
cur_replay.ReadData(mainGame->dInfo.clientname_tag, 40);
cur_replay.ReadData(mainGame->dInfo.clientname, 40);
cur_replay.ReadName(mainGame->dInfo.hostname);
cur_replay.ReadName(mainGame->dInfo.hostname_tag);
cur_replay.ReadName(mainGame->dInfo.clientname_tag);
cur_replay.ReadName(mainGame->dInfo.clientname);
mainGame->dInfo.isTag = true;
mainGame->dInfo.tag_player[0] = false;
mainGame->dInfo.tag_player[1] = false;
} else {
cur_replay.ReadData(mainGame->dInfo.hostname, 40);
cur_replay.ReadData(mainGame->dInfo.clientname, 40);
cur_replay.ReadName(mainGame->dInfo.hostname);
cur_replay.ReadName(mainGame->dInfo.clientname);
}
set_script_reader(default_script_reader);
set_card_reader((card_reader)DataManager::CardReader);
......@@ -205,16 +205,16 @@ void ReplayMode::Restart(bool refresh) {
int seed = rh.seed;
rnd.reset(seed);
if(rh.flag & REPLAY_TAG) {
cur_replay.ReadData(mainGame->dInfo.hostname, 40);
cur_replay.ReadData(mainGame->dInfo.hostname_tag, 40);
cur_replay.ReadData(mainGame->dInfo.clientname_tag, 40);
cur_replay.ReadData(mainGame->dInfo.clientname, 40);
cur_replay.ReadName(mainGame->dInfo.hostname);
cur_replay.ReadName(mainGame->dInfo.hostname_tag);
cur_replay.ReadName(mainGame->dInfo.clientname_tag);
cur_replay.ReadName(mainGame->dInfo.clientname);
mainGame->dInfo.isTag = true;
mainGame->dInfo.tag_player[0] = false;
mainGame->dInfo.tag_player[1] = false;
} else {
cur_replay.ReadData(mainGame->dInfo.hostname, 40);
cur_replay.ReadData(mainGame->dInfo.clientname, 40);
cur_replay.ReadName(mainGame->dInfo.hostname);
cur_replay.ReadName(mainGame->dInfo.clientname);
}
//set_card_reader((card_reader)DataManager::CardReader);
//set_message_handler((message_handler)MessageHandler);
......
......@@ -814,8 +814,8 @@
#!setname 0xec 魔界 魔界
!setname 0x10ec 魔界剧团 魔界劇団
!setname 0x20ec 魔界台本 魔界台本
!setname 0xed底恐魔 Subterror
!setname 0x10ed底恐魔 巨魔 Subterror Behemoth
!setname 0xed中族 サブテラー
!setname 0x10ed中族邪界 サブテラーマリス
!setname 0xee 秘旋谍 SPYRAL
!setname 0x10ee 秘旋谍装备 SPYRAL GEAR
!setname 0x20ee 秘旋谍任务 SPYRAL MISSION
......@@ -847,7 +847,7 @@
!setname 0x103 幻变骚灵 オルターガイスト
!setname 0x104 机怪虫 クローラー
!setname 0x105 玄化 メタファイズ
!setname 0x106 复仇死Vendread
!setname 0x107 F.A.
!setname 0x106 复仇死者 ヴェンデット
!setname 0x107 方程式运动员 F.A.
!setname 0x108 魔弹 魔弾
!setname 0x109 天气 天気
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