Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Xu Chenxi
ygopro2
Commits
1f856fa0
Commit
1f856fa0
authored
Apr 10, 2019
by
mercury233
Committed by
Unicorn369
Apr 10, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add windows resize and maximize, fix GetProcessWnd
parent
9dd77920
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
84 additions
and
12 deletions
+84
-12
Assets/SibylSystem/MonoHelpers/UIHelper.cs
Assets/SibylSystem/MonoHelpers/UIHelper.cs
+58
-9
Assets/SibylSystem/Program.cs
Assets/SibylSystem/Program.cs
+6
-0
Assets/SibylSystem/Setting/Setting.cs
Assets/SibylSystem/Setting/Setting.cs
+18
-1
ProjectSettings/ProjectSettings.asset
ProjectSettings/ProjectSettings.asset
+2
-2
No files found.
Assets/SibylSystem/MonoHelpers/UIHelper.cs
View file @
1f856fa0
...
...
@@ -2,6 +2,7 @@
using
System.Collections
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.Text
;
using
System.Runtime.InteropServices
;
using
UnityEngine
;
using
YGOSharp.OCGWrapper.Enums
;
...
...
@@ -11,31 +12,45 @@ public static class UIHelper
[
DllImport
(
"user32"
)]
static
extern
bool
FlashWindow
(
IntPtr
handle
,
bool
invert
);
public
delegate
bool
WNDENUMPROC
(
IntPtr
hwnd
,
uint
lParam
);
public
delegate
bool
WNDENUMPROC
(
IntPtr
hwnd
,
IntPtr
lParam
);
[
DllImport
(
"user32"
,
SetLastError
=
true
)]
static
extern
bool
EnumWindows
(
WNDENUMPROC
lpEnumFunc
,
uint
lParam
);
static
extern
bool
EnumWindows
(
WNDENUMPROC
lpEnumFunc
,
IntPtr
lParam
);
[
DllImport
(
"user32"
,
SetLastError
=
true
)]
static
extern
IntPtr
GetParent
(
IntPtr
hWnd
);
[
DllImport
(
"user32"
)]
static
extern
uint
GetWindowThreadProcessId
(
IntPtr
hWnd
,
ref
uint
lpdwProcessId
);
static
extern
uint
GetWindowThreadProcessId
(
IntPtr
hWnd
,
ref
IntPtr
lpdwProcessId
);
[
DllImport
(
"user32"
)]
static
extern
int
GetClassNameW
(
IntPtr
hWnd
,
[
MarshalAs
(
UnmanagedType
.
LPWStr
)]
StringBuilder
lpString
,
int
nMaxCount
);
[
DllImport
(
"user32"
)]
static
extern
bool
IsZoomed
(
IntPtr
hWnd
);
[
DllImport
(
"user32"
)]
static
extern
bool
ShowWindow
(
IntPtr
hWnd
,
int
nCmdShow
);
[
DllImport
(
"kernel32"
)]
static
extern
void
SetLastError
(
uint
dwErrCode
);
static
IntPtr
myHWND
=
IntPtr
.
Zero
;
static
IntPtr
GetProcessWnd
()
{
if
(
myHWND
!=
IntPtr
.
Zero
)
return
myHWND
;
IntPtr
ptrWnd
=
IntPtr
.
Zero
;
uint
pid
=
(
uint
)
System
.
Diagnostics
.
Process
.
GetCurrentProcess
().
Id
;
// 当前进程 ID
IntPtr
pid
=
(
IntPtr
)
System
.
Diagnostics
.
Process
.
GetCurrentProcess
().
Id
;
// 当前进程 ID
bool
bResult
=
EnumWindows
(
new
WNDENUMPROC
(
delegate
(
IntPtr
hwnd
,
uint
lParam
)
bool
bResult
=
EnumWindows
(
new
WNDENUMPROC
(
delegate
(
IntPtr
hwnd
,
IntPtr
mypid
)
{
uint
id
=
0
;
IntPtr
id
=
IntPtr
.
Zero
;
StringBuilder
ClassName
=
new
StringBuilder
(
256
);
GetClassNameW
(
hwnd
,
ClassName
,
ClassName
.
Capacity
);
if
(
GetParent
(
hwnd
)
==
IntPtr
.
Zero
)
if
(
string
.
Compare
(
ClassName
.
ToString
(),
"UnityWndClass"
,
true
,
System
.
Globalization
.
CultureInfo
.
InvariantCulture
)
==
0
)
{
GetWindowThreadProcessId
(
hwnd
,
ref
id
);
if
(
id
==
lParam
)
// 找到进程对应的主窗口句柄
if
(
id
==
mypid
)
// 找到进程对应的主窗口句柄
{
ptrWnd
=
hwnd
;
// 把句柄缓存起来
SetLastError
(
0
);
// 设置无错误
...
...
@@ -47,7 +62,12 @@ public static class UIHelper
}),
pid
);
return
(!
bResult
&&
Marshal
.
GetLastWin32Error
()
==
0
)
?
ptrWnd
:
IntPtr
.
Zero
;
if
(!
bResult
&&
Marshal
.
GetLastWin32Error
()
==
0
)
{
myHWND
=
ptrWnd
;
}
return
myHWND
;
}
public
static
void
Flash
()
...
...
@@ -55,6 +75,35 @@ public static class UIHelper
FlashWindow
(
GetProcessWnd
(),
true
);
}
public
static
bool
isMaximized
()
{
#if UNITY_STANDALONE_WIN
return
IsZoomed
(
GetProcessWnd
());
#else
// not a easy thing to check window status on non-windows desktop...
return
false
;
#endif
}
public
static
void
MaximizeWindow
()
{
#if UNITY_STANDALONE_WIN
ShowWindow
(
GetProcessWnd
(),
3
);
// SW_MAXIMIZE
#endif
}
public
static
void
RestoreWindow
()
{
#if UNITY_STANDALONE_WIN
ShowWindow
(
GetProcessWnd
(),
9
);
// SW_RESTORE
#endif
}
public
static
bool
shouldMaximize
()
{
return
fromStringToBool
(
Config
.
Get
(
"maximize_"
,
"0"
));
}
public
enum
RenderingMode
{
Opaque
,
...
...
Assets/SibylSystem/Program.cs
View file @
1f856fa0
...
...
@@ -1183,6 +1183,8 @@ public class Program : MonoBehaviour
{
preWid
=
Screen
.
width
;
preheight
=
Screen
.
height
;
//if (setting != null)
// setting.setScreenSizeValue();
Program
.
notGo
(
fixScreenProblems
);
Program
.
go
(
500
,
fixScreenProblems
);
}
...
...
@@ -1196,6 +1198,10 @@ public class Program : MonoBehaviour
void
gameStart
()
{
if
(
UIHelper
.
shouldMaximize
())
{
UIHelper
.
MaximizeWindow
();
}
backGroundPic
.
show
();
shiftToServant
(
menu
);
}
...
...
Assets/SibylSystem/Setting/Setting.cs
View file @
1f856fa0
...
...
@@ -15,7 +15,6 @@ public class Setting : WindowServant2D
UIHelper
.
registEvent
(
gameObject
,
"full_"
,
resizeScreen
);
UIHelper
.
registEvent
(
gameObject
,
"resize_"
,
resizeScreen
);
UIHelper
.
getByName
<
UIToggle
>(
gameObject
,
"full_"
).
value
=
Screen
.
fullScreen
;
UIHelper
.
getByName
<
UIPopupList
>(
gameObject
,
"screen_"
).
value
=
Screen
.
width
.
ToString
()
+
"*"
+
Screen
.
height
.
ToString
();
UIHelper
.
getByName
<
UIToggle
>(
gameObject
,
"ignoreWatcher_"
).
value
=
UIHelper
.
fromStringToBool
(
Config
.
Get
(
"ignoreWatcher_"
,
"0"
));
UIHelper
.
getByName
<
UIToggle
>(
gameObject
,
"ignoreOP_"
).
value
=
UIHelper
.
fromStringToBool
(
Config
.
Get
(
"ignoreOP_"
,
"0"
));
UIHelper
.
getByName
<
UIToggle
>(
gameObject
,
"smartSelect_"
).
value
=
UIHelper
.
fromStringToBool
(
Config
.
Get
(
"smartSelect_"
,
"1"
));
...
...
@@ -77,6 +76,7 @@ public class Setting : WindowServant2D
UIHelper
.
registEvent
(
setting
.
Vlink
.
gameObject
,
onCP
);
onchangeMouse
();
onchangeCloud
();
setScreenSizeValue
();
}
private
void
onchangeFPS
()
...
...
@@ -121,6 +121,14 @@ public class Setting : WindowServant2D
Program
.
I
().
mouseParticle
.
SetActive
(
setting
.
mouseEffect
.
value
);
}
//private int dontResizeTwice = 2;
public
void
setScreenSizeValue
()
{
//dontResizeTwice = 3;
UIHelper
.
getByName
<
UIPopupList
>(
gameObject
,
"screen_"
).
value
=
Screen
.
width
.
ToString
()
+
"*"
+
Screen
.
height
.
ToString
();
}
void
onCP
()
{
try
...
...
@@ -221,6 +229,14 @@ public class Setting : WindowServant2D
void
resizeScreen
()
{
//if (dontResizeTwice > 0)
//{
// dontResizeTwice--;
// return;
//}
//dontResizeTwice = 2;
if
(
UIHelper
.
isMaximized
())
UIHelper
.
RestoreWindow
();
string
[]
mats
=
UIHelper
.
getByName
<
UIPopupList
>(
gameObject
,
"screen_"
).
value
.
Split
(
new
string
[]
{
"*"
},
StringSplitOptions
.
RemoveEmptyEntries
);
if
(
mats
.
Length
==
2
)
{
...
...
@@ -247,6 +263,7 @@ public class Setting : WindowServant2D
Config
.
Set
(
"showoffStar"
,
setting
.
showoffStar
.
value
.
ToString
());
Config
.
Set
(
"LimFPS"
,
setting
.
LimFPS
.
value
.
ToString
());
Config
.
Set
(
"resize_"
,
UIHelper
.
fromBoolToString
(
UIHelper
.
getByName
<
UIToggle
>(
gameObject
,
"resize_"
).
value
));
Config
.
Set
(
"maximize_"
,
UIHelper
.
fromBoolToString
(
UIHelper
.
isMaximized
()));
}
public
void
save
()
...
...
ProjectSettings/ProjectSettings.asset
View file @
1f856fa0
...
...
@@ -15,7 +15,7 @@ PlayerSettings:
defaultCursor
:
{
fileID
:
0
}
cursorHotspot
:
{
x
:
0
,
y
:
0
}
m_SplashScreenBackgroundColor
:
{
r
:
0.13333334
,
g
:
0.17254902
,
b
:
0.21176471
,
a
:
1
}
m_ShowUnitySplashScreen
:
1
m_ShowUnitySplashScreen
:
0
m_ShowUnitySplashLogo
:
1
m_SplashScreenOverlayOpacity
:
1
m_SplashScreenAnimation
:
1
...
...
@@ -76,7 +76,7 @@ PlayerSettings:
usePlayerLog
:
1
bakeCollisionMeshes
:
0
forceSingleInstance
:
0
resizableWindow
:
0
resizableWindow
:
1
useMacAppStoreValidation
:
0
macAppStoreCategory
:
public.app-category.games
gpuSkinning
:
0
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment