Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

android/ios适配 #3

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/[Ll]ibrary/
/[Tt]emp/
/[Oo]bj/
/[Bb]uild/
/[Bb]uilds/
/Assets/AssetStoreTools*

# Autogenerated VS/MD solution and project files
ExportedObj/
*.csproj
*.unityproj
*.sln
*.suo
*.tmp
*.user
*.userprefs
*.pidb
*.booproj
*.svd


# Unity3D generated meta files
*.pidb.meta

# Unity3D Generated File On Crash Reports
sysinfo.txt

# Builds
*.apk
*.unitypackage
Temp/
ygo2/
/ygoandroid
obj
/AI_core_vs2017solution/libs
73 changes: 73 additions & 0 deletions AI_core_vs2017solution/Android.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := ocgcore

NDK_PROJECT_PATH := $(LOCAL_PATH)
ifndef NDEBUG
LOCAL_CFLAGS += -g -D_DEBUG
else
LOCAL_CFLAGS += -fexpensive-optimizations -O3
endif

ifeq ($(TARGET_ARCH_ABI),x86)
LOCAL_CFLAGS += -fno-stack-protector
endif

#ifeq ($(TARGET_ARCH_ABI), armeabi-v7a)
#LOCAL_CFLAGS += -mno-unaligned-access
#endif
LOCAL_C_INCLUDES := $(LOCAL_PATH)/ocgcore

LOCAL_SRC_FILES := ocgcore/lapi.c \
ocgcore/lauxlib.c \
ocgcore/lbaselib.c \
ocgcore/lbitlib.c \
ocgcore/lcode.c \
ocgcore/lcorolib.c \
ocgcore/lctype.c \
ocgcore/ldblib.c \
ocgcore/ldebug.c \
ocgcore/ldo.c \
ocgcore/ldump.c \
ocgcore/lfunc.c \
ocgcore/lgc.c \
ocgcore/linit.c \
ocgcore/liolib.c \
ocgcore/llex.c \
ocgcore/lmathlib.c \
ocgcore/lmem.c \
ocgcore/loadlib.c \
ocgcore/lobject.c \
ocgcore/lopcodes.c \
ocgcore/loslib.c \
ocgcore/lparser.c \
ocgcore/lstate.c \
ocgcore/lstring.c \
ocgcore/lstrlib.c \
ocgcore/ltable.c \
ocgcore/ltablib.c \
ocgcore/ltm.c \
ocgcore/lundump.c \
ocgcore/lvm.c \
ocgcore/lzio.c \
ocgcore/card.cpp \
ocgcore/duel.cpp \
ocgcore/effect.cpp \
ocgcore/field.cpp \
ocgcore/group.cpp \
ocgcore/interpreter.cpp \
ocgcore/libcard.cpp \
ocgcore/libdebug.cpp \
ocgcore/libduel.cpp \
ocgcore/libeffect.cpp \
ocgcore/libgroup.cpp \
ocgcore/mem.cpp \
ocgcore/ocgapi.cpp \
ocgcore/operations.cpp \
ocgcore/playerop.cpp \
ocgcore/processor.cpp \
ocgcore/scriptlib.cpp \

LOCAL_LDLIBS := -llog
include $(BUILD_SHARED_LIBRARY)

6 changes: 6 additions & 0 deletions AI_core_vs2017solution/Application.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
APP_BUILD_SCRIPT := Android.mk
APP_PLATFORM :=android-14
APP_ABI := armeabi-v7a x86
APP_STL := gnustl_static
APP_CPPFLAGS := -Wno-error=format-security -std=gnu++11 -fpermissive -fexceptions
APP_OPTIM := release
1 change: 1 addition & 0 deletions AI_core_vs2017solution/how-build-android.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ndk-build NDK_PROJECT_PATH=. NDK_APPLICATION_MK=Application.mk
4 changes: 3 additions & 1 deletion AI_core_vs2017solution/ocgcore/llex.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,9 @@ static void buffreplace (LexState *ls, char from, char to) {
while (n--)
if (p[n] == from) p[n] = to;
}

#if __ANDROID__
#define getlocaledecpoint() ('.')
#endif

#if !defined(getlocaledecpoint)
#define getlocaledecpoint() (localeconv()->decimal_point[0])
Expand Down
2 changes: 1 addition & 1 deletion AI_core_vs2017solution/ocgcore/ocgapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#ifndef OCGAPI_H_
#define OCGAPI_H_
#define WIN32
//#define WIN32
#include "common.h"
#ifdef WIN32
#include <windows.h>
Expand Down
2 changes: 1 addition & 1 deletion Assets/ArtSystem/gameInfo/barPngLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void Start () {
api_timeBar.mainTexture = GameTextureManager.time;
try
{
string[] allLines = (File.ReadAllText("texture\\duel\\healthBar\\config.txt").Replace("\r", "").Replace(" ", "").Split("\n"));
string[] allLines = (File.ReadAllText("texture/duel/healthBar/config.txt").Replace("\r", "").Replace(" ", "").Split("\n"));
foreach (var item in allLines)
{
string[] mats = item.Split("=");
Expand Down
9 changes: 0 additions & 9 deletions Assets/ArtSystem/glacxy.meta

This file was deleted.

9 changes: 0 additions & 9 deletions Assets/ArtSystem/proico.meta

This file was deleted.

2 changes: 1 addition & 1 deletion Assets/NGUI/Scripts/Internal/NGUITools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ static public string GetHierarchy (GameObject obj)
while (obj.transform.parent != null)
{
obj = obj.transform.parent.gameObject;
path = obj.name + "\\" + path;
path = obj.name + "/" + path;
}
return path;
}
Expand Down
8 changes: 0 additions & 8 deletions Assets/Plugins/7zip/Compress/LzmaAlone/LzmaAlone.csproj.meta

This file was deleted.

8 changes: 0 additions & 8 deletions Assets/Plugins/7zip/Compress/LzmaAlone/LzmaAlone.sln.meta

This file was deleted.

5 changes: 5 additions & 0 deletions Assets/Plugins/Android.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/Plugins/Android/libocgcore.so
Binary file not shown.
14 changes: 14 additions & 0 deletions Assets/Plugins/Android/libocgcore.so.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/Plugins/Android/libsqlite3.so
Binary file not shown.
4 changes: 4 additions & 0 deletions Assets/Plugins/Android/libsqlite3.so.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 0 additions & 9 deletions Assets/Plugins/high_light.meta

This file was deleted.

2 changes: 1 addition & 1 deletion Assets/SibylSystem/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static string Getui(string original)
if (loaded == false)
{
loaded = true;
string[] lines = File.ReadAllText("texture\\ui\\config.txt").Replace("\r", "").Replace(" ", "").Split("\n");
string[] lines = File.ReadAllText("texture/ui/config.txt").Replace("\r", "").Replace(" ", "").Split("\n");
for (int i = 0; i < lines.Length; i++)
{
string[] mats = lines[i].Split("=");
Expand Down
10 changes: 5 additions & 5 deletions Assets/SibylSystem/MonoHelpers/UIHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
using UnityEngine;
public static class UIHelper
{
[DllImport("user32.dll")]
[DllImport("user32l")]
static extern bool FlashWindow(IntPtr handle, bool invert);

public delegate bool WNDENUMPROC(IntPtr hwnd, uint lParam);
[DllImport("user32.dll", SetLastError = true)]
[DllImport("user32", SetLastError = true)]
static extern bool EnumWindows(WNDENUMPROC lpEnumFunc, uint lParam);

[DllImport("user32.dll", SetLastError = true)]
[DllImport("user32", SetLastError = true)]
static extern IntPtr GetParent(IntPtr hWnd);
[DllImport("user32.dll")]
[DllImport("user32")]
static extern uint GetWindowThreadProcessId(IntPtr hWnd, ref uint lpdwProcessId);

[DllImport("kernel32.dll")]
[DllImport("kernel32")]
static extern void SetLastError(uint dwErrCode);

static IntPtr GetProcessWnd()
Expand Down
4 changes: 2 additions & 2 deletions Assets/SibylSystem/Ocgcore/OCGobjects/gameCard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2263,7 +2263,7 @@ public void animation_show_off(bool summon, bool disabled = false)
}
else if (show_off_shokewave)
{
if (Program.I().setting.setting.showoff.value == false || File.Exists("picture\\closeup\\" + data.Id.ToString() + ".png") == false || (data.Attack < Program.I().setting.atk && data.Level < Program.I().setting.star))
if (Program.I().setting.setting.showoff.value == false || File.Exists("picture/closeup/" + data.Id.ToString() + ".png") == false || (data.Attack < Program.I().setting.atk && data.Level < Program.I().setting.star))
{
refreshFunctions.Add(SOH_nSum);
Program.I().ocgcore.Sleep(30);
Expand All @@ -2276,7 +2276,7 @@ public void animation_show_off(bool summon, bool disabled = false)
}
else
{
if (Program.I().setting.setting.showoffWhenActived.value == false || File.Exists("picture\\closeup\\" + data.Id.ToString() + ".png") == false)
if (Program.I().setting.setting.showoffWhenActived.value == false || File.Exists("picture/closeup/" + data.Id.ToString() + ".png") == false)
{
refreshFunctions.Add(SOH_nAct);
Program.I().ocgcore.Sleep(42);
Expand Down
48 changes: 30 additions & 18 deletions Assets/SibylSystem/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,13 @@ public static float getVerticalTransparency()

void initialize()
{

#if (UNITY_ANDROID || UNITY_IPHONE)
Environment.CurrentDirectory = Application.persistentDataPath;
System.IO.Directory.SetCurrentDirectory (Application.persistentDataPath);
#else
Environment.CurrentDirectory = System.Windows.Forms.Application.StartupPath;
System.IO.Directory.SetCurrentDirectory (System.Windows.Forms.Application.StartupPath);
#endif
go(1, () =>
{
UIHelper.iniFaces();
Expand All @@ -285,19 +291,19 @@ void initialize()
});
go(300, () =>
{
InterString.initialize("config\\translation.conf");
InterString.initialize("config/translation.conf");
GameTextureManager.initialize();
Config.initialize("config\\config.conf");
GameStringManager.initialize("config\\strings.conf");
if (File.Exists("cdb\\strings.conf"))
Config.initialize("config/config.conf");
GameStringManager.initialize("config/strings.conf");
if (File.Exists("cdb/strings.conf"))
{
GameStringManager.initialize("cdb\\strings.conf");
GameStringManager.initialize("cdb/strings.conf");
}
if (File.Exists("diy\\strings.conf"))
if (File.Exists("diy/strings.conf"))
{
GameStringManager.initialize("diy\\strings.conf");
GameStringManager.initialize("diy/strings.conf");
}
YGOSharp.BanlistManager.initialize("config\\lflist.conf");
YGOSharp.BanlistManager.initialize("config/lflist.conf");

var fileInfos = (new DirectoryInfo("cdb")).GetFiles();
for (int i = 0; i < fileInfos.Length; i++)
Expand All @@ -306,7 +312,7 @@ void initialize()
{
if (fileInfos[i].Name.Substring(fileInfos[i].Name.Length - 4, 4) == ".cdb")
{
YGOSharp.CardsManager.initialize("cdb\\" + fileInfos[i].Name);
YGOSharp.CardsManager.initialize("cdb/" + fileInfos[i].Name);
}
}
}
Expand All @@ -320,7 +326,7 @@ void initialize()
{
if (fileInfos[i].Name.Substring(fileInfos[i].Name.Length - 4, 4) == ".cdb")
{
YGOSharp.CardsManager.initialize("diy\\" + fileInfos[i].Name);
YGOSharp.CardsManager.initialize("diy/" + fileInfos[i].Name);
}
}
}
Expand All @@ -334,7 +340,7 @@ void initialize()
{
if (fileInfos[i].Name.Substring(fileInfos[i].Name.Length - 3, 3) == ".db")
{
YGOSharp.PacksManager.initialize("pack\\" + fileInfos[i].Name);
YGOSharp.PacksManager.initialize("pack/" + fileInfos[i].Name);
}
}
}
Expand Down Expand Up @@ -825,12 +831,18 @@ public void shiftToServant(Servant to)

void Start()
{
if (Screen.width < 100 || Screen.height < 100)
{
Screen.SetResolution(1300, 700, false);
}
Application.targetFrameRate = 120;
mouseParticle = Instantiate(new_mouse);
#if (UNITY_ANDROID || UNITY_IPHONE)
Screen.SetResolution(1366, 768, true);
Application.targetFrameRate = -1;
#else
if (Screen.width < 100 || Screen.height < 100)
{
Screen.SetResolution(1300, 700, false);
}
Application.targetFrameRate = 120;
#endif

mouseParticle = Instantiate(new_mouse);
instance = this;
initialize();
go(500, () => { gameStart(); });
Expand Down
Loading