Commit 25d39a8f authored by kenan's avatar kenan
parents 5f03ee56 e6f5ed58
......@@ -200,10 +200,10 @@ void Game::DrawBackGround() {
} else {
driver->drawVertexPrimitiveList(matManager.vTotalAtkopT, 4, matManager.iRectangle, 2);
DrawShadowText(numFont, dInfo.str_total_attack[1], recti(740 * mainGame->xScale, 295 * mainGame->yScale, 760 * mainGame->xScale, 315 * mainGame->yScale), recti(0, 1, 2, 0), dInfo.total_attack_color[1], 0xff000000, true, false, 0);
}
}
//disabled field
{
/*float cv[4] = {0.0f, 0.0f, 1.0f, 1.0f};*/
......@@ -475,7 +475,7 @@ void Game::DrawCard(ClientCard* pcard) {
}
void Game::DrawShadowText(CGUITTFont * font, const core::stringw & text, const core::rect<s32>& position, const core::rect<s32>& padding,
video::SColor color, video::SColor shadowcolor, bool hcenter, bool vcenter, const core::rect<s32>* clip) {
core::rect<s32> shadowposition = recti(position.UpperLeftCorner.X - padding.UpperLeftCorner.X, position.UpperLeftCorner.Y - padding.UpperLeftCorner.Y,
core::rect<s32> shadowposition = recti(position.UpperLeftCorner.X - padding.UpperLeftCorner.X, position.UpperLeftCorner.Y - padding.UpperLeftCorner.Y,
position.LowerRightCorner.X - padding.LowerRightCorner.X, position.LowerRightCorner.Y - padding.LowerRightCorner.Y);
font->draw(text, shadowposition, shadowcolor, hcenter, vcenter, clip);
font->draw(text, position, color, hcenter, vcenter, clip);
......@@ -634,7 +634,7 @@ void Game::DrawMisc() {
DrawShadowText(numFont, dInfo.str_card_count[0], recti(550 * mainGame->xScale, 49 * mainGame->yScale, 575 * mainGame->xScale, 68 * mainGame->yScale), recti(0, 1 * mainGame->yScale, 2 * mainGame->xScale, 0), dInfo.card_count_color[0], 0xff000000, true, false, 0);
DrawShadowText(numFont, dInfo.str_card_count[1], recti(757 * mainGame->xScale, 49 * mainGame->yScale, 782 * mainGame->xScale, 68 * mainGame->yScale), recti(0, 1 * mainGame->yScale, 2 * mainGame->xScale, 0), dInfo.card_count_color[1], 0xff000000, true, false, 0);
/*
driver->draw2DRectangle(recti(525 * mainGame->xScale, 34 * mainGame->yScale, (525 + dInfo.time_left[0] * 100 / dInfo.time_limit) * mainGame->xScale, 44 * mainGame->yScale), 0xa0e0e0e0, 0xa0e0e0e0, 0xa0c0c0c0, 0xa0c0c0c0);
driver->draw2DRectangleOutline(recti(525 * mainGame->xScale, 34 * mainGame->yScale, 625 * mainGame->xScale, 44 * mainGame->yScale), 0xffffffff);
......
......@@ -83,14 +83,14 @@ void Game::onHandleAndroidCommand(ANDROID_APP app, int32_t cmd){
ygo::mainGame->playBGM();
}
break;
case APP_CMD_INIT_WINDOW:
case APP_CMD_WINDOW_RESIZED:
case APP_CMD_STOP:
case APP_CMD_INIT_WINDOW:
case APP_CMD_SAVE_STATE:
case APP_CMD_TERM_WINDOW:
case APP_CMD_GAINED_FOCUS:
case APP_CMD_LOST_FOCUS:
case APP_CMD_DESTROY:
case APP_CMD_WINDOW_RESIZED:
default:
break;
}
......@@ -131,7 +131,6 @@ bool Game::Initialize(ANDROID_APP app, android::InitOptions *options) {
ILogger* logger = device->getLogger();
// logger->setLogLevel(ELL_WARNING);
isPSEnabled = options->isPendulumScaleEnabled();
soundManager = Utils::make_unique<SoundManager>();
dataManager.FileSystem = device->getFileSystem();
((CIrrDeviceAndroid*)device)->onAppCmd = onHandleAndroidCommand;
......@@ -1199,6 +1198,7 @@ bool Game::Initialize(ANDROID_APP app, android::InitOptions *options) {
btnCancelOrFinish = env->addButton(rect<s32>(200 * yScale, 205 * yScale, 310 * yScale, 255 * yScale), 0, BUTTON_CANCEL_OR_FINISH, dataManager.GetSysString(1295));
ChangeToIGUIImageButton(btnCancelOrFinish, imageManager.tButton_S, imageManager.tButton_S_pressed);
btnCancelOrFinish->setVisible(false);
soundManager = Utils::make_unique<SoundManager>();
if(!soundManager->Init((double)gameConf.sound_volume / 100, (double)gameConf.music_volume / 100, gameConf.enable_sound, gameConf.enable_music, nullptr)) {
chkEnableSound->setChecked(false);
chkEnableSound->setEnabled(false);
......@@ -2079,7 +2079,7 @@ void Game::ChangeToIGUIImageButton(irr::gui::IGUIButton* button, irr::video::ITe
button->setOverrideFont(font);
}
void Game::OnGameClose() const {
void Game::OnGameClose() {
android::onGameExit(appMain);
this->device->closeDevice();
}
......
......@@ -6,8 +6,6 @@
#include "deck_con.h"
#include "menu_handler.h"
#include "sound_manager.h"
#include "deck_manager.h"
#include "image_manager.h"
#include <unordered_map>
#include <vector>
#include <list>
......@@ -154,7 +152,7 @@ public:
void DrawBackGround();
void DrawSelField(int player, int loc, size_t seq, irr::video::ITexture* texture, bool reverse = false, bool spin = false);
void DrawLinkedZones(ClientCard* pcard, ClientCard* fcard = 0);
void CheckMutual(ClientCard* pcard, int mark){}
void CheckMutual(ClientCard* pcard, int mark);
void DrawCards();
void DrawCard(ClientCard* pcard);
void DrawShadowText(irr::gui::CGUITTFont* font, const core::stringw& text, const core::rect<s32>& position, const core::rect<s32>& padding, video::SColor color = 0xffffffff, video::SColor shadowcolor = 0xff000000, bool hcenter = false, bool vcenter = false, const core::rect<s32>* clip = 0);
......@@ -184,9 +182,9 @@ public:
void CloseGameButtons();
void CloseGameWindow();
void CloseDuelWindow();
void OnGameClose() const;
void OnGameClose();
void ChangeToIGUIImageWindow(irr::gui::IGUIWindow* window, irr::gui::IGUIImage* bgwindow, irr::video::ITexture* image);
static void ChangeToIGUIImageButton(irr::gui::IGUIButton* button, irr::video::ITexture* image, irr::video::ITexture* pressedImage, irr::gui::CGUITTFont* font=0);
void ChangeToIGUIImageButton(irr::gui::IGUIButton* button, irr::video::ITexture* image, irr::video::ITexture* pressedImage, irr::gui::CGUITTFont* font=0);
int LocalPlayer(int player);
const wchar_t* LocalName(int local_player);
......
......@@ -45,14 +45,11 @@ void android_main(ANDROID_APP app) {
int main(int argc, char* argv[]) {
#endif
evthread_use_pthreads();
auto game = new ygo::Game;
// if(ygo::mainGame != nullptr){
// delete ygo::mainGame;
// }
ygo::mainGame = game;
ygo::Game _game;
ygo::mainGame = &_game;
#ifdef _IRR_ANDROID_PLATFORM_
android::InitOptions *options = android::getInitOptions(app);
if(!game->Initialize(app, options)){
if(!ygo::mainGame->Initialize(app, options)){
delete options;
return;
}
......@@ -87,22 +84,22 @@ int main(int argc, char* argv[]) {
keep_on_return = true;
} else if(!strcmp(arg, "-c")) { // Create host
exit_on_return = !keep_on_return;
game->HideElement(game->wMainMenu);
ClickButton(game->btnJoinHost);
ygo::mainGame->HideElement(ygo::mainGame->wMainMenu);
ClickButton(ygo::mainGame->btnJoinHost);
break;
} else if(!strcmp(arg, "-j")) { // Join host
exit_on_return = !keep_on_return;
game->HideElement(game->wMainMenu);
ClickButton(game->btnJoinHost);
ygo::mainGame->HideElement(ygo::mainGame->wMainMenu);
ClickButton(ygo::mainGame->btnJoinHost);
break;
} else if(!strcmp(arg, "-r")) { // Replay
exit_on_return = !keep_on_return;
//显示录像窗口
game->HideElement(game->wMainMenu);
game->ShowElement(game->wReplay);
game->ebRepStartTurn->setText(L"1");
game->stReplayInfo->setText(L"");
game->RefreshReplay();
ygo::mainGame->HideElement(ygo::mainGame->wMainMenu);
ygo::mainGame->ShowElement(ygo::mainGame->wReplay);
ygo::mainGame->ebRepStartTurn->setText(L"1");
ygo::mainGame->stReplayInfo->setText(L"");
ygo::mainGame->RefreshReplay();
int index = -1;
if((i+1) < argc){//下一个参数是录像名
#ifdef _IRR_ANDROID_PLATFORM_
......@@ -113,24 +110,24 @@ int main(int argc, char* argv[]) {
wchar_t fname[1024];
BufferIO::DecodeUTF8(name, fname);
index = GetListBoxIndex(game->lstReplayList, fname);
index = GetListBoxIndex(ygo::mainGame->lstReplayList, fname);
ALOGD("open replay file:index=%d, name=%s", index, name);
}
game->HideElement(game->wMainMenu);
ClickButton(game->btnReplayMode);
ygo::mainGame->HideElement(ygo::mainGame->wMainMenu);
ClickButton(ygo::mainGame->btnReplayMode);
if (index >= 0) {
game->lstReplayList->setSelected(index);
ClickButton(game->btnLoadReplay);
ygo::mainGame->lstReplayList->setSelected(index);
ClickButton(ygo::mainGame->btnLoadReplay);
}
break;//只播放一个
} else if(!strcmp(arg, "-s")) { // Single
exit_on_return = !keep_on_return;
//显示残局窗口
game->HideElement(game->wMainMenu);
game->ShowElement(game->wSinglePlay);
game->RefreshSingleplay();
game->RefreshBot();
ygo::mainGame->HideElement(ygo::mainGame->wMainMenu);
ygo::mainGame->ShowElement(ygo::mainGame->wSinglePlay);
ygo::mainGame->RefreshSingleplay();
ygo::mainGame->RefreshBot();
int index = -1;
if((i+1) < argc){//下一个参数是文件名
#ifdef _IRR_ANDROID_PLATFORM_
......@@ -140,12 +137,12 @@ int main(int argc, char* argv[]) {
#endif
wchar_t fname[1024];
BufferIO::DecodeUTF8(name, fname);
index = GetListBoxIndex(game->lstSinglePlayList, fname);
index = GetListBoxIndex(ygo::mainGame->lstSinglePlayList, fname);
ALOGD("open single file:index=%d, name=%s", index, name);
}
if(index >= 0){
game->lstSinglePlayList->setSelected(index);
ClickButton(game->btnLoadSinglePlay);
ygo::mainGame->lstSinglePlayList->setSelected(index);
ClickButton(ygo::mainGame->btnLoadSinglePlay);
}
break;
}
......@@ -153,8 +150,8 @@ int main(int argc, char* argv[]) {
#ifdef _IRR_ANDROID_PLATFORM_
delete options;
#endif
game->externalSignal.Set();
game->externalSignal.SetNoWait(true);
game->MainLoop();
ygo::mainGame->externalSignal.Set();
ygo::mainGame->externalSignal.SetNoWait(true);
ygo::mainGame->MainLoop();
return;
}
#include "netserver.h"
#include "single_duel.h"
#include "tag_duel.h"
#include "game.h"
namespace ygo {
std::unordered_map<bufferevent*, DuelPlayer> NetServer::users;
......
......@@ -121,8 +121,8 @@ namespace ygo {
}
}
void Utils::changeCursor(irr::IrrlichtDevice* device, irr::gui::ECURSOR_ICON icon) {
irr::gui::ICursorControl* cursor = device->getCursorControl();
void Utils::changeCursor(irr::gui::ECURSOR_ICON icon) {
irr::gui::ICursorControl* cursor = mainGame->device->getCursorControl();
if (cursor->getActiveIcon() != icon) {
cursor->setActiveIcon(icon);
}
......@@ -205,8 +205,8 @@ namespace ygo {
return res;
}
irr::io::IReadFile* Utils::FindandOpenFileFromArchives(std::vector<Utils::IrrArchiveHelper> archives, const path_string & path, const path_string & name) {
for(auto& archive : archives) {
irr::io::IReadFile* Utils::FindandOpenFileFromArchives(const path_string & path, const path_string & name) {
for(auto& archive : mainGame->archives) {
int res = -1;
Utils::FindfolderFiles(archive, path, [match = &name, &res](int index, path_string name, bool isdir, void* payload)->bool {
if(isdir)
......
......@@ -35,12 +35,13 @@ namespace ygo {
static bool Deletedirectory(const path_string& source);
static void CreateResourceFolders();
static void takeScreenshot(irr::IrrlichtDevice* device);
static void changeCursor(irr::IrrlichtDevice* device, irr::gui::ECURSOR_ICON icon);
static void ToggleFullscreen();
static void changeCursor(irr::gui::ECURSOR_ICON icon);
static void FindfolderFiles(const path_string& path, const std::function<void(path_string, bool, void*)>& cb, void* payload = nullptr);
static std::vector<path_string> FindfolderFiles(const path_string& path, std::vector<path_string> extensions, int subdirectorylayers = 0);
static void FindfolderFiles(IrrArchiveHelper& archive, const path_string& path, const std::function<bool(int, path_string, bool, void*)>& cb, void* payload = nullptr);
static std::vector<int> FindfolderFiles(IrrArchiveHelper& archive, const path_string& path, std::vector<path_string> extensions, int subdirectorylayers = 0);
static irr::io::IReadFile* FindandOpenFileFromArchives(std::vector<Utils::IrrArchiveHelper> archives, const path_string& path, const path_string& name);
static irr::io::IReadFile* FindandOpenFileFromArchives(const path_string& path, const path_string& name);
static std::wstring NormalizePath(std::wstring path, bool trailing_slash = true);
static std::wstring GetFileExtension(std::wstring file);
static std::wstring GetFilePath(std::wstring file);
......
......@@ -186,6 +186,7 @@ static void* join_game_thread(void* param) {
ygo::mainGame->gMutex.unlock();
return NULL;
}
//auto exit when join game by mycard.
exit_on_return = true;
irr::android::YGOGameOptions options = irr::android::YGOGameOptions(param);
irr::SEvent event;
......
......@@ -9,7 +9,7 @@ android {
minSdkVersion 21
//noinspection ExpiredTargetSdkVersion
targetSdkVersion 29
versionCode 380901001
versionCode 380901004
versionName "3.8.9"
flavorDimensions "versionCode"
vectorDrawables.useSupportLibrary = true
......
......@@ -687,10 +687,4 @@ public class AppsSettings {
// Log.i("kk", "saveTemp:" + array);
mSharedPreferences.putString(Constants.PREF_LAST_ROOM_LIST, array.toString());
}
@Deprecated
//获取收藏文件
public File getFavoriteFile() {
return new File(getResourcePath(), "/favorite.txt");
}
}
......@@ -19,12 +19,14 @@ import android.util.Base64;
import android.util.Log;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import cn.garymb.ygomobile.Constants;
import cn.garymb.ygomobile.ui.cards.deck.DeckUtils;
import cn.garymb.ygomobile.utils.FileLogUtil;
import cn.garymb.ygomobile.utils.YGOUtil;
public class Deck implements Parcelable {
......@@ -146,15 +148,23 @@ public class Deck implements Parcelable {
int mNum = Integer.valueOf(YGOUtil.getArrayString(bits, 0, 8), 2);
int eNum = Integer.valueOf(YGOUtil.getArrayString(bits, 8, 12), 2);
int sNum = Integer.valueOf(YGOUtil.getArrayString(bits, 12, 16), 2);
try {
FileLogUtil.write("种类数量"+mNum+" "+eNum+" "+sNum+" ");
FileLogUtil.write("m:"+YGOUtil.getArrayString(bits, 0, 8));
FileLogUtil.write("s:"+YGOUtil.getArrayString(bits, 8, 12));
FileLogUtil.write("e:"+YGOUtil.getArrayString(bits, 12, 16));
} catch (IOException e) {
e.printStackTrace();
}
Log.e("Deck","种类数量"+mNum+" "+eNum+" "+sNum+" ");
Log.e("Deck","m:"+YGOUtil.getArrayString(bits, 0, 8));
Log.e("Deck","e:"+YGOUtil.getArrayString(bits, 8, 16));
Log.e("Deck","s:"+YGOUtil.getArrayString(bits, 16, 24));
Log.e("Deck","e:"+YGOUtil.getArrayString(bits, 8, 12));
Log.e("Deck","s:"+YGOUtil.getArrayString(bits, 12, 16));
for (int i = 0; i < mNum; i++) {
int cStart = 16 + (i * 29);
int cardNum = Integer.valueOf(YGOUtil.getArrayString(bits, cStart, cStart + 2), 2);
int cardId = Integer.valueOf(YGOUtil.getArrayString(bits, cStart + 2, cStart + 29), 2);
if (i<4)
for (int x = 0; x < cardNum; x++) {
mainlist.add(cardId);
}
......
......@@ -6,45 +6,39 @@ import cn.garymb.ygomobile.bean.TextSelect;
public class DeckFile extends TextSelect {
private String name;
private String path;
private Long date;
private final File path;
private final String fullName;
public DeckFile(String path) {
this.path = path;
name = new File(path).getName();
int end = name.lastIndexOf(".");
if (end != -1)
name = name.substring(0, end);
super.setName(name);
setObject(this);
this(new File(path));
}
public DeckFile(File file) {
path = file.getAbsolutePath();
name = file.getName();
name = name.substring(0, name.lastIndexOf("."));
date = file.lastModified();
path = file;
fullName = file.getName();
String name = fullName;
int index = name.lastIndexOf(".");
if(index > 0) {
name = name.substring(0, index);
}
super.setName(name);
setObject(this);
}
public String getName() {
return name;
public String getFileName() {
return fullName;
}
public void setName(String name) {
this.name = name;
public File getPathFile() {
return path;
}
public String getPath() {
return path;
return path.getAbsolutePath();
}
public void setPath(String path) {
this.path = path;
public Long getDate() {
return path.lastModified();
}
public Long getDate() { return date; }
}
......@@ -7,6 +7,7 @@ import androidx.annotation.NonNull;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import ocgcore.DataManager;
import ocgcore.data.Card;
......@@ -20,32 +21,33 @@ public class CardKeyWord {
public CardKeyWord(String word) {
this.word = word;
if (!TextUtils.isEmpty(word)) {
if (TextUtils.isDigitsOnly(word) && word.length() > 5) {
if (TextUtils.isDigitsOnly(word) && word.length() >= 5) {
//搜索卡密
filterList.add(new CodeFilter(Long.parseLong(word)));
}
String[] ws = word.split(" ");
for (String w : ws) {
if (TextUtils.isEmpty(w)) {
continue;
}
boolean exclude = false;
if (w.startsWith("-")) {
exclude = true;
w = w.substring(1);
}
boolean onlyText = false;
if (w.startsWith("\"") || w.startsWith("“") || w.startsWith("”")) {
//只搜索文字
onlyText = true;
if (w.endsWith("\"") || w.endsWith("“") || w.endsWith("”")) {
w = w.substring(1, w.length() - 1);
} else {
} else {
String[] ws = word.split(" ");
for (String w : ws) {
if (TextUtils.isEmpty(w)) {
continue;
}
boolean exclude = false;
if (w.startsWith("-")) {
exclude = true;
w = w.substring(1);
}
boolean onlyText = false;
if (w.startsWith("\"") || w.startsWith("“") || w.startsWith("”")) {
//只搜索文字
onlyText = true;
if (w.endsWith("\"") || w.endsWith("“") || w.endsWith("”")) {
w = w.substring(1, w.length() - 1);
} else {
w = w.substring(1);
}
}
Log.d(TAG, "filter:word=" + w + ", exclude=" + exclude + ", onlyText=" + onlyText);
filterList.add(new NameFilter(w, exclude, onlyText));
}
Log.d(TAG, "filter:word=" + w + ", exclude=" + exclude + ", onlyText=" + onlyText);
filterList.add(new NameFilter(w, exclude, onlyText));
}
}
empty = filterList.size() == 0;
......@@ -76,7 +78,7 @@ public class CardKeyWord {
public NameFilter(@NonNull String word, boolean exclude, boolean onlyText) {
this.setcode = onlyText ? 0 : DataManager.get().getStringManager().getSetCode(word);
this.exclude = exclude;
this.word = word.toLowerCase();
this.word = word.toLowerCase(Locale.US);
if(this.setcode > 0){
Log.d(TAG, "filter:setcode=" + setcode + ", exclude=" + exclude + ", word=" + word);
}
......
......@@ -73,25 +73,8 @@ public class CardFavorites {
public void load() {
mList.clear();
File config = AppsSettings.get().getFavoriteFile();
List<String> lines;
if (config.exists()) {
//重命名
if (!config.renameTo(AppsSettings.get().getSystemConfig())) {
Log.w(TAG, "copy txt to conf");
try {
FileUtils.copyFile(AppsSettings.get().getFavoriteFile().getPath(), AppsSettings.get().getSystemConfig().getPath());
} catch (IOException e) {
//TODO 复制失败,直接删除?
FileUtils.deleteFile(AppsSettings.get().getFavoriteFile());
}
} else {
Log.d(TAG, "rename txt to conf");
}
config = AppsSettings.get().getSystemConfig();
} else {
config = AppsSettings.get().getSystemConfig();
}
File config = AppsSettings.get().getSystemConfig();
if (!config.exists()) {
Log.w(TAG, "config is no exists:" + config.getPath());
return;
......
......@@ -26,7 +26,6 @@ import cn.garymb.ygomobile.ui.adapters.SimpleSpinnerAdapter;
import cn.garymb.ygomobile.ui.adapters.SimpleSpinnerItem;
import cn.garymb.ygomobile.ui.plus.DialogPlus;
import cn.garymb.ygomobile.ui.plus.VUiKit;
import cn.garymb.ygomobile.ui.widget.SearchableSpinner;
import ocgcore.DataManager;
import ocgcore.LimitManager;
import ocgcore.StringManager;
......@@ -56,7 +55,7 @@ public class CardSearcher implements View.OnClickListener {
private final Spinner typeMonsterSpinner2;
private final Spinner typeSpellSpinner;
private final Spinner typeTrapSpinner;
private final SearchableSpinner setCodeSpinner;
private final Spinner setCodeSpinner;
private final Spinner categorySpinner;
private final Spinner raceSpinner;
private final Spinner levelSpinner;
......@@ -441,7 +440,7 @@ public class CardSearcher implements View.OnClickListener {
private void initSetNameSpinners(Spinner spinner) {
List<CardSet> setnames = mStringManager.getCardSets();
List<SimpleSpinnerItem> items = new ArrayList<>();
items.add(new SimpleSpinnerItem(0, mContext.getString(R.string.label_set)));
items.add(new SimpleSpinnerItem(0, getString(R.string.label_set)));
for (CardSet set : setnames) {
items.add(new SimpleSpinnerItem(set.getCode(), set.getName()));
}
......
......@@ -1122,7 +1122,7 @@ public class DeckManagerActivity extends BaseCardsActivity implements RecyclerVi
@Override
public void onDeckSelect(DeckFile deckFile) {
loadDeckFromFile(new File(deckFile.getPath()));
loadDeckFromFile(deckFile.getPathFile());
}
@Override
......@@ -1132,7 +1132,7 @@ public class DeckManagerActivity extends BaseCardsActivity implements RecyclerVi
return;
String currentDeckPath = deck.getAbsolutePath();
for (DeckFile deckFile : deckFileList) {
if (deckFile.getPath().equals(currentDeckPath)) {
if (TextUtils.equals(deckFile.getPath(), currentDeckPath)) {
List<File> files = getYdkFiles();
File file = null;
if (files != null && files.size() > 0) {
......@@ -1157,7 +1157,7 @@ public class DeckManagerActivity extends BaseCardsActivity implements RecyclerVi
String currentDeckPath = ydk.getPath();
for (DeckFile deckFile : deckFileList) {
if (TextUtils.equals(currentDeckPath, deckFile.getPath())) {
loadDeckFromFile(new File(toDeckType.getPath(), deckFile.getName() + ".ydk"));
loadDeckFromFile(new File(toDeckType.getPath(), deckFile.getFileName()));
return;
}
}
......@@ -1172,7 +1172,7 @@ public class DeckManagerActivity extends BaseCardsActivity implements RecyclerVi
String currentDeckPath = ydk.getPath();
for (DeckFile deckFile : deckFileList) {
if (TextUtils.equals(currentDeckPath, deckFile.getPath())) {
loadDeckFromFile(new File(toDeckType.getPath(), deckFile.getName() + ".ydk"));
loadDeckFromFile(new File(toDeckType.getPath(), deckFile.getFileName()));
return;
}
}
......
......@@ -40,6 +40,8 @@ public class MyCard {
private static final String mArenaUrl = "https://mycard.moe/ygopro/arena/";
private static final String mCommunityUrl = "https://ygobbs.com/login";
private static final String return_sso_url = "https://mycard.moe/mobile/?";
private static final String HOST_MC = "mycard.moe";
private static final String MC_MAIN_URL = "https://mycard.moe/mobile/ygopro/lobby";
private static final Charset UTF_8 = Charset.forName("UTF-8");
private final DefWebViewClient mDefWebViewClient;
private final User mUser = new User();
......@@ -125,6 +127,14 @@ public class MyCard {
return mCommunityUrl;
}
public String getMcHost() {
return HOST_MC;
}
public String getMcMainUrl() {
return MC_MAIN_URL;
}
@SuppressLint("AddJavascriptInterface")
public void attachWeb(MyCardWebView webView, MyCardListener myCardListener) {
mMyCardListener = myCardListener;
......
......@@ -11,6 +11,7 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
import android.view.MenuItem;
import android.view.View;
......@@ -67,6 +68,7 @@ public class MyCardActivity extends BaseActivity implements MyCard.MyCardListene
}
};
private ProgressBar mProgressBar;
private TextView tv_back_mc;
private ValueCallback<Uri> uploadMessage;
private ValueCallback<Uri[]> mUploadCallbackAboveL;
......@@ -86,6 +88,7 @@ public class MyCardActivity extends BaseActivity implements MyCard.MyCardListene
mWebViewPlus = $(R.id.webbrowser);
mDrawerlayout = $(R.id.drawer_layout);
mProgressBar = $(R.id.progressBar);
tv_back_mc = $(R.id.tv_back_mc);
mProgressBar.setMax(100);
NavigationView navigationView = $(R.id.nav_main);
......@@ -96,6 +99,8 @@ public class MyCardActivity extends BaseActivity implements MyCard.MyCardListene
mStatusView = navHead.findViewById(R.id.tv_dp);
//mWebViewPlus.enableHtml5();
tv_back_mc.setOnClickListener(view-> onHome());
WebSettings settings = mWebViewPlus.getSettings();
settings.setUserAgentString(settings.getUserAgentString() + MessageFormat.format(
" YGOMobile/{0} ({1} {2,number,#})",
......@@ -109,6 +114,10 @@ public class MyCardActivity extends BaseActivity implements MyCard.MyCardListene
public void onProgressChanged(WebView view, int newProgress) {
if (newProgress == 100) {
mProgressBar.setVisibility(View.GONE);
if (view.getUrl().contains(mMyCard.getMcHost()))
tv_back_mc.setVisibility(View.GONE);
else
tv_back_mc.setVisibility(View.VISIBLE);
} else {
if (View.GONE == mProgressBar.getVisibility()) {
mProgressBar.setVisibility(View.VISIBLE);
......@@ -195,6 +204,10 @@ public class MyCardActivity extends BaseActivity implements MyCard.MyCardListene
closeDrawer();
return;
}
if (mWebViewPlus.getUrl().equals(mMyCard.getMcMainUrl())) {
finish();
return;
}
if (mWebViewPlus.canGoBack()) {
mWebViewPlus.goBack();
} else {
......
......@@ -10,33 +10,20 @@ public class CardUtils {
public static String getAllTypeString(Card card, StringManager stringManager) {
StringBuilder stringBuilder = new StringBuilder();
CardType[] cardTypes = CardType.values();
if (card.isType(CardType.Spell) || card.isType(CardType.Trap)) {
for (CardType type : cardTypes) {
if(type == CardType.Spell || type == CardType.Trap){
continue;
boolean isFirst = true;
for (CardType type : cardTypes) {
if (card.isType(type)) {
if (!isFirst) {
stringBuilder.append("/");
} else {
isFirst = false;
}
if (card.isType(type)) {
stringBuilder.append(stringManager.getTypeString(type.getId()));
}
}
//先显示速攻,后显示魔法
stringBuilder.append(stringManager.getTypeString(CardType.Spell.getId()));
} else {
boolean isFrst = true;
for (CardType type : cardTypes) {
if (card.isType(type)) {
if (!isFrst) {
stringBuilder.append("/");
} else {
isFrst = false;
}
String str = stringManager.getTypeString(type.getId());
if (TextUtils.isEmpty(str)) {
stringBuilder.append("0x");
stringBuilder.append(String.format("%X", type.getId()));
} else {
stringBuilder.append(str);
}
String str = stringManager.getTypeString(type.getId());
if (TextUtils.isEmpty(str)) {
stringBuilder.append("0x");
stringBuilder.append(String.format("%X", type.getId()));
} else {
stringBuilder.append(str);
}
}
}
......
......@@ -60,7 +60,8 @@ public class YGODialogUtil {
private final Dialog ygoDialog;
public ViewHolder(Context context, String selectDeckPath, OnDeckMenuListener onDeckMenuListener){
View viewDialog = DialogUtils.getdx(context).dialogBottomSheet(R.layout.dialog_deck_select, 0);
DialogUtils du = DialogUtils.getdx(context);
View viewDialog = du.dialogBottomSheet(R.layout.dialog_deck_select, 0);
RecyclerView rv_type, rv_deck;
rv_deck = viewDialog.findViewById(R.id.rv_deck);
......@@ -129,7 +130,6 @@ public class YGODialogUtil {
public void onItemSelect(int position, DeckType item) {
clearDeckSelect();
deckList.clear();
Log.d("kk-test", "read path"+item.getPath());
deckList.addAll(DeckUtil.getDeckList(item.getPath()));
if (position == 0) {
if (AppsSettings.get().isReadExpansions()) {
......@@ -176,12 +176,12 @@ public class YGODialogUtil {
ll_add.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
DialogUtils.getdx(context).dialogl(context.getString(R.string.new_deck),
du.dialogl(context.getString(R.string.new_deck),
new String[]{context.getString(R.string.category_name),
context.getString(R.string.deck_name)}, R.drawable.radius).setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
DialogUtils.getdx(context).dis();
du.dis();
switch (position) {
case 0:
//if (deckList.size()>=8){
......@@ -223,53 +223,43 @@ public class YGODialogUtil {
}
});
ll_move.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
List<DeckType> otherType = getOtherTypeList();
DialogUtils.getdx(context).dialogl(context.getString(please_select_target_category),
getStringType(otherType),
R.drawable.radius).setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
DialogUtils.getdx(context).dis();
DeckType toType = otherType.get(position);
IOUtils.createFolder(new File(toType.getPath()));
List<DeckFile> deckFileList = deckAdp.getSelectList();
for (DeckFile deckFile : deckFileList) {
try {
FileUtils.moveFile(deckFile.getPath(), new File(toType.getPath(), deckFile.getName() + ".ydk").getPath());
} catch (IOException e) {
e.printStackTrace();
}
deckList.remove(deckFile);
ll_move.setOnClickListener(v -> {
List<DeckType> otherType = getOtherTypeList();
du.dialogl(context.getString(please_select_target_category),
getStringType(otherType),
R.drawable.radius).setOnItemClickListener((parent, view, position, id) -> {
du.dis();
DeckType toType = otherType.get(position);
IOUtils.createFolder(new File(toType.getPath()));
List<DeckFile> deckFileList = deckAdp.getSelectList();
for (DeckFile deckFile : deckFileList) {
try {
FileUtils.moveFile(deckFile.getPath(), new File(toType.getPath(), deckFile.getFileName()).getPath());
} catch (IOException e) {
e.printStackTrace();
}
YGOUtil.show(context.getString(R.string.done));
onDeckMenuListener.onDeckMove(deckAdp.getSelectList(), toType);
clearDeckSelect();
deckList.remove(deckFile);
}
});
}
YGOUtil.show(context.getString(R.string.done));
onDeckMenuListener.onDeckMove(deckAdp.getSelectList(), toType);
clearDeckSelect();
});
});
ll_copy.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
List<DeckType> otherType = getOtherTypeList();
ll_copy.setOnClickListener(v -> {
List<DeckType> otherType = getOtherTypeList();
DialogUtils.getdx(context).dialogl(context.getString(please_select_target_category),
getStringType(otherType),
R.drawable.radius).setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
DialogUtils.getdx(context).dis();
du.dialogl(context.getString(please_select_target_category),
getStringType(otherType),
R.drawable.radius).setOnItemClickListener((parent, view, position, id) -> {
du.dis();
DeckType toType = otherType.get(position);
IOUtils.createFolder(new File(toType.getPath()));
List<DeckFile> deckFileList = deckAdp.getSelectList();
for (DeckFile deckFile : deckFileList) {
try {
FileUtils.copyFile(deckFile.getPath(), new File(toType.getPath(), deckFile.getName() + ".ydk").getPath());
FileUtils.copyFile(deckFile.getPath(), new File(toType.getPath(), deckFile.getFileName()).getPath());
} catch (IOException e) {
e.printStackTrace();
}
......@@ -277,9 +267,7 @@ public class YGODialogUtil {
YGOUtil.show(context.getString(R.string.done));
onDeckMenuListener.onDeckCopy(deckAdp.getSelectList(), toType);
clearDeckSelect();
}
});
}
});
});
ll_del.setOnClickListener(new View.OnClickListener() {
......@@ -298,7 +286,7 @@ public class YGODialogUtil {
public void onClick(DialogInterface dialog, int which) {
List<DeckFile> selectDeckList = deckAdp.getSelectList();
for (DeckFile deckFile : selectDeckList) {
new File(deckFile.getPath()).delete();
deckFile.getPathFile().delete();
deckList.remove(deckFile);
}
YGOUtil.show(context.getString(R.string.done));
......@@ -317,7 +305,7 @@ public class YGODialogUtil {
}
});
ygoDialog = DialogUtils.getdx(context).getDialog();
ygoDialog = du.getDialog();
ygoDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
......
......@@ -7,6 +7,8 @@ import android.text.TextUtils;
import androidx.annotation.NonNull;
import java.util.Locale;
import ocgcore.enums.CardType;
public class Card extends CardData implements Parcelable {
......@@ -153,11 +155,11 @@ public class Card extends CardData implements Parcelable {
}
public boolean containsName(String key){
return Name != null && Name.toLowerCase().contains(key);
return Name != null && Name.toLowerCase(Locale.US).contains(key);
}
public boolean containsDesc(String key){
return Desc != null && Desc.toLowerCase().contains(key);
return Desc != null && Desc.toLowerCase(Locale.US).contains(key);
}
/**
......
......@@ -11,10 +11,25 @@
tools:openDrawer="left">
<RelativeLayout
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.appcompat.widget.AppCompatTextView
android:visibility="gone"
android:id="@+id/tv_back_mc"
android:background="@drawable/click_background"
android:textColor="@color/black"
android:layout_width="match_parent"
android:text="返回萌卡大厅"
android:textSize="13sp"
android:textStyle="bold"
android:gravity="center"
android:paddingTop="6dp"
android:paddingBottom="6dp"
android:layout_height="wrap_content"/>
<cn.garymb.ygomobile.ui.mycard.MyCardWebView
android:id="@+id/webbrowser"
android:layout_width="match_parent"
......@@ -28,7 +43,7 @@
</cn.garymb.ygomobile.ui.mycard.MyCardWebView>
</RelativeLayout>
</LinearLayout>
<com.google.android.material.navigation.NavigationView
android:id="@+id/nav_main"
......
......@@ -316,6 +316,6 @@
<string name="label_ot_All">모든 카드</string>
<string name="label_ot_No_Exclusive">ID 없는 카드</string>
<string name="label_ot_CUSTOM">커스텀 카드</string>
<string name="settings_screen_padding">曲面屏预留高度</string>
<string name="tip_load_cdb_error">加载数据出错</string>
<string name="settings_screen_padding">화면 스타일</string>
<string name="tip_load_cdb_error">데이터를 불러오는 중에 오류가 발생했습니다.</string>
</resources>
......@@ -316,6 +316,6 @@
<string name="ask_delete_ex">点击确认以清空</string>
<string name="about_delete_ex">如果遇到拓展卡包问题时删除是个不错的办法</string>
<string name="file_installed">文件已导入</string>
<string name="settings_screen_padding">曲面屏预留高度</string>
<string name="settings_screen_padding">瀑布屏预留高度</string>
<string name="tip_load_cdb_error">加载数据出错</string>
</resources>
......@@ -327,6 +327,5 @@
<string name="label_ot_No_Exclusive">No exclusive</string>
<string name="label_ot_SC_OCG">SChinese OCG</string>
<string name="settings_screen_padding">Reserved height of curved screen</string>
<string name="tip_load_cdb_error">加载数据出错</string>
<string name="text_none" translatable="false">N/A</string>
<string name="tip_load_cdb_error">Load database error</string>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="@string/settings_about_sub_about">
<Preference
android:key="pref_key_about_author"
android:summary="@string/settings_author"
android:title="@string/settings_about_author_pref" />
<Preference
android:key="pref_key_about_version"
android:persistent="true"
android:title="@string/settings_about_version_pref" />
<Preference
android:key="pref_key_open_alipay"
android:persistent="true"
android:title="@string/donation" />
<Preference
android:key="pref_key_about_check_update"
android:persistent="true"
android:title="@string/settings_about_check_update" />
<Preference
android:key="pref_key_change_log"
android:title="@string/settings_about_change_log" />
</PreferenceCategory>
</PreferenceScreen>
\ No newline at end of file
......@@ -12,6 +12,7 @@
android:action="android.intent.action.VIEW"
android:targetClass="cn.garymb.ygomobile.ui.mycard.MyCardActivity"
android:targetPackage="cn.garymb.ygomobile" />
<categories android:name="android.shortcut.conversation" />
</shortcut>
<shortcut
android:enabled="true"
......@@ -25,6 +26,7 @@
android:action="android.intent.action.VIEW"
android:targetClass="cn.garymb.ygomobile.ui.cards.CardSearchActivity"
android:targetPackage="cn.garymb.ygomobile" />
<categories android:name="android.shortcut.conversation" />
</shortcut>
<shortcut
android:enabled="true"
......@@ -38,5 +40,6 @@
android:action="android.intent.action.VIEW"
android:targetClass="cn.garymb.ygomobile.ui.cards.DeckManagerActivity"
android:targetPackage="cn.garymb.ygomobile" />
<categories android:name="android.shortcut.conversation" />
</shortcut>
</shortcuts>
\ No newline at end of file
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