Skip to content

Commit 9ecd0a2

Browse files
committed
android and control fix
1 parent 878013d commit 9ecd0a2

File tree

15 files changed

+280
-244
lines changed

15 files changed

+280
-244
lines changed

Assets/PCInput.cs

Lines changed: 119 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -4,131 +4,131 @@
44

55
public class PCInput : MonoBehaviour
66
{
7-
private static Touch[] fakeTouches = new Touch[0];
8-
9-
public static Touch GetTouch(int index)
10-
{
11-
if (Application.isMobilePlatform)
12-
{
13-
return Input.GetTouch(index);
14-
}
15-
16-
return fakeTouches[index];
17-
}
18-
19-
public static int touchCount
20-
{
21-
get
22-
{
23-
if (Application.isMobilePlatform)
24-
{
25-
return Input.touchCount;
26-
}
27-
28-
return fakeTouches.Length;
29-
}
30-
}
31-
32-
public static Touch[] touches
33-
{
34-
get
35-
{
36-
if (Application.isMobilePlatform)
37-
{
38-
return Input.touches;
39-
}
40-
41-
return fakeTouches;
42-
}
43-
}
44-
45-
private static Vector3 lastPosition;
46-
47-
private static float deltaTime;
7+
//private static Touch[] fakeTouches = new Touch[0];
8+
//
9+
//public static Touch GetTouch(int index)
10+
//{
11+
// if (Application.isMobilePlatform)
12+
// {
13+
// return Input.GetTouch(index);
14+
// }
15+
//
16+
// return fakeTouches[index];
17+
//}
18+
//
19+
//public static int touchCount
20+
//{
21+
// get
22+
// {
23+
// if (Application.isMobilePlatform)
24+
// {
25+
// return Input.touchCount;
26+
// }
27+
//
28+
// return fakeTouches.Length;
29+
// }
30+
//}
31+
//
32+
//public static Touch[] touches
33+
//{
34+
// get
35+
// {
36+
// if (Application.isMobilePlatform)
37+
// {
38+
// return Input.touches;
39+
// }
40+
//
41+
// return fakeTouches;
42+
// }
43+
//}
44+
//
45+
//private static Vector3 lastPosition;
46+
//
47+
//private static float deltaTime;
4848

4949
private void Start()
5050
{
5151
Application.targetFrameRate = 240;
5252

53-
if (Application.isMobilePlatform)
54-
{
55-
return;
56-
}
53+
//if (Application.isMobilePlatform)
54+
//{
55+
// return;
56+
//}
5757

58-
DontDestroyOnLoad(gameObject);
58+
//DontDestroyOnLoad(gameObject);
5959
}
6060

61-
private void Update()
62-
{
63-
if (Application.isMobilePlatform)
64-
{
65-
return;
66-
}
67-
68-
if (Input.GetKeyDown(KeyCode.F1))
69-
{
70-
Screen.lockCursor = !Screen.lockCursor;
71-
}
72-
73-
if (!Screen.lockCursor)
74-
{
75-
if (Input.GetMouseButtonDown(0))
76-
{
77-
lastPosition = Input.mousePosition;
78-
79-
fakeTouches = new Touch[1]
80-
{
81-
new Touch()
82-
{
83-
position = Input.mousePosition,
84-
phase = TouchPhase.Began
85-
}
86-
};
87-
88-
return;
89-
}
90-
91-
if (Input.GetMouseButton(0))
92-
{
93-
deltaTime += Time.deltaTime;
94-
95-
fakeTouches = new Touch[1]
96-
{
97-
new Touch()
98-
{
99-
position = Input.mousePosition,
100-
deltaPosition = Input.mousePosition - lastPosition,
101-
deltaTime = deltaTime,
102-
phase = TouchPhase.Moved
103-
}
104-
};
105-
106-
lastPosition = Input.mousePosition;
107-
return;
108-
}
109-
if (Input.GetMouseButtonUp(0))
110-
{
111-
fakeTouches = new Touch[1]
112-
{
113-
new Touch()
114-
{
115-
position = Input.mousePosition,
116-
deltaPosition = Input.mousePosition - lastPosition,
117-
deltaTime = deltaTime,
118-
phase = TouchPhase.Ended
119-
}
120-
};
121-
122-
lastPosition = Vector2.zero;
123-
deltaTime = 0f;
124-
125-
return;
126-
}
127-
}
128-
129-
fakeTouches = new Touch[0];
130-
131-
lastPosition = Vector2.zero;
132-
deltaTime = 0f;
133-
}
61+
//private void Update()
62+
//{
63+
// if (Application.isMobilePlatform)
64+
// {
65+
// return;
66+
// }
67+
//
68+
// if (Input.GetKeyDown(KeyCode.F1))
69+
// {
70+
// Screen.lockCursor = !Screen.lockCursor;
71+
// }
72+
//
73+
// if (!Screen.lockCursor)
74+
// {
75+
// if (Input.GetMouseButtonDown(0))
76+
// {
77+
// lastPosition = Input.mousePosition;
78+
//
79+
// fakeTouches = new Touch[1]
80+
// {
81+
// new Touch()
82+
// {
83+
// position = Input.mousePosition,
84+
// phase = TouchPhase.Began
85+
// }
86+
// };
87+
//
88+
// return;
89+
// }
90+
//
91+
// if (Input.GetMouseButton(0))
92+
// {
93+
// deltaTime += Time.deltaTime;
94+
//
95+
// fakeTouches = new Touch[1]
96+
// {
97+
// new Touch()
98+
// {
99+
// position = Input.mousePosition,
100+
// deltaPosition = Input.mousePosition - lastPosition,
101+
// deltaTime = deltaTime,
102+
// phase = TouchPhase.Moved
103+
// }
104+
// };
105+
//
106+
// lastPosition = Input.mousePosition;
107+
// return;
108+
// }
109+
// if (Input.GetMouseButtonUp(0))
110+
// {
111+
// fakeTouches = new Touch[1]
112+
// {
113+
// new Touch()
114+
// {
115+
// position = Input.mousePosition,
116+
// deltaPosition = Input.mousePosition - lastPosition,
117+
// deltaTime = deltaTime,
118+
// phase = TouchPhase.Ended
119+
// }
120+
// };
121+
//
122+
// lastPosition = Vector2.zero;
123+
// deltaTime = 0f;
124+
//
125+
// return;
126+
// }
127+
// }
128+
//
129+
// fakeTouches = new Touch[0];
130+
//
131+
// lastPosition = Vector2.zero;
132+
// deltaTime = 0f;
133+
//}
134134
}

Assets/Scripts/Assembly-CSharp-firstpass/Glu/Plugins.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Scripts/Assembly-CSharp-firstpass/Glu/Plugins/AAds.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Scripts/Assembly-CSharp/BundleAssetInfo.cs

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -149,43 +149,53 @@ public void Serialize(string language)
149149
}
150150
}
151151

152+
public static byte[] ReadBundle(string path)
153+
{
154+
if (!Application.isMobilePlatform)
155+
{
156+
return File.ReadAllBytes(path);
157+
}
158+
using (WWW www = new WWW(path))
159+
{
160+
while (!www.isDone)
161+
{
162+
// I am not implementing a coroutine for this
163+
}
164+
return www.bytes;
165+
}
166+
}
167+
152168
public void DeserializeBundleAssetInfo()
153169
{
154170
if (AssetList.Count > 0 || AssetToBundleList.Count > 0)
155171
{
156172
return;
157173
}
158174
string systemLanguage = BundleUtils.GetSystemLanguage();
159-
using (FileStream fileStream = new FileStream(AssetBundleConfig.BundleDataPath + "/" + systemLanguage + "/" + AssetBundleConfig.BundleAssetInfoName, FileMode.Open, FileAccess.Read, FileShare.Read))
175+
byte[] info = ReadBundle(AssetBundleConfig.BundleDataPath + "/" + systemLanguage + "/" + AssetBundleConfig.BundleAssetInfoName);
176+
using (MemoryStream stream = new MemoryStream(info))
160177
{
161178
try
162179
{
163180
BinaryFormatter binaryFormatter = new BinaryFormatter();
164-
AssetToBundleList = (Dictionary<short, List<short>>)binaryFormatter.Deserialize(fileStream);
165-
BundleDependencyList = (Dictionary<short, List<short>>)binaryFormatter.Deserialize(fileStream);
181+
AssetToBundleList = (Dictionary<short, List<short>>)binaryFormatter.Deserialize(stream);
182+
BundleDependencyList = (Dictionary<short, List<short>>)binaryFormatter.Deserialize(stream);
166183
}
167184
catch (SerializationException)
168185
{
169186
}
170-
finally
171-
{
172-
fileStream.Close();
173-
}
174187
}
175-
using (FileStream fileStream2 = new FileStream(AssetBundleConfig.BundleDataPath + "/" + systemLanguage + "/" + AssetBundleConfig.BundleAssetList, FileMode.Open, FileAccess.Read, FileShare.Read))
188+
byte[] list = ReadBundle(AssetBundleConfig.BundleDataPath + "/" + systemLanguage + "/" + AssetBundleConfig.BundleAssetList);
189+
using (MemoryStream stream2 = new MemoryStream(list))
176190
{
177191
try
178192
{
179193
BinaryFormatter binaryFormatter2 = new BinaryFormatter();
180-
AssetList = (List<string>)binaryFormatter2.Deserialize(fileStream2);
194+
AssetList = (List<string>)binaryFormatter2.Deserialize(stream2);
181195
}
182196
catch (SerializationException)
183197
{
184198
}
185-
finally
186-
{
187-
fileStream2.Close();
188-
}
189199
}
190200
if (AssetList.Count > 0)
191201
{

Assets/Scripts/Assembly-CSharp/DataBundleSerializer.cs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -189,20 +189,17 @@ public static Hashtable DeserializeHashTable()
189189
{
190190
Hashtable hashtable = null;
191191
string systemLanguage = BundleUtils.GetSystemLanguage();
192-
using (FileStream fileStream = new FileStream(AssetBundleConfig.BundleDataPath + "/" + systemLanguage + "/" + AssetBundleConfig.DataBundleName, FileMode.Open, FileAccess.Read, FileShare.Read))
192+
byte[] table = BundleAssetInfo.ReadBundle(AssetBundleConfig.BundleDataPath + "/" + systemLanguage + "/" + AssetBundleConfig.DataBundleName);
193+
using (MemoryStream stream = new MemoryStream(table))
193194
{
194195
try
195196
{
196197
BinaryFormatter binaryFormatter = new BinaryFormatter();
197-
hashtable = (Hashtable)binaryFormatter.Deserialize(fileStream);
198+
hashtable = (Hashtable)binaryFormatter.Deserialize(stream);
198199
}
199200
catch (SerializationException)
200201
{
201202
}
202-
finally
203-
{
204-
fileStream.Close();
205-
}
206203
}
207204
if (hashtable.ContainsKey(AssetBundleConfig.VersionKey))
208205
{
@@ -219,20 +216,17 @@ public static List<string> DeserializeStringList()
219216
{
220217
string systemLanguage = BundleUtils.GetSystemLanguage();
221218
List<string> list = null;
222-
using (FileStream fileStream = new FileStream(AssetBundleConfig.BundleDataPath + "/" + systemLanguage + "/" + AssetBundleConfig.DataBundleStringList, FileMode.Open, FileAccess.Read, FileShare.Read))
219+
byte[] listBytes = BundleAssetInfo.ReadBundle(AssetBundleConfig.BundleDataPath + "/" + systemLanguage + "/" + AssetBundleConfig.DataBundleStringList);
220+
using (MemoryStream stream = new MemoryStream(listBytes))
223221
{
224222
try
225223
{
226224
BinaryFormatter binaryFormatter = new BinaryFormatter();
227-
list = (List<string>)binaryFormatter.Deserialize(fileStream);
225+
list = (List<string>)binaryFormatter.Deserialize(stream);
228226
}
229227
catch (SerializationException)
230228
{
231229
}
232-
finally
233-
{
234-
fileStream.Close();
235-
}
236230
}
237231
if (list.Count > 0)
238232
{

Assets/Scripts/Assembly-CSharp/DebugMain.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ private void Update()
7979

8080
private void UpdateConsoleShowControls()
8181
{
82-
if ((PCInput.touchCount == 4 && (Allow4TouchActivate || Singleton<GrConsole>.Instance.Visible)) || (Input.GetKey(KeyCode.RightAlt) && Input.GetKey(KeyCode.LeftAlt)) || (Input.GetKey(KeyCode.LeftBracket) && Input.GetKey(KeyCode.RightBracket)) || (AJavaTools.Properties.IsBuildAmazon() && PCInput.touchCount == 2))
82+
if ((Input.touchCount == 4 && (Allow4TouchActivate || Singleton<GrConsole>.Instance.Visible)) || (Input.GetKey(KeyCode.RightAlt) && Input.GetKey(KeyCode.LeftAlt)) || (Input.GetKey(KeyCode.LeftBracket) && Input.GetKey(KeyCode.RightBracket)) || (AJavaTools.Properties.IsBuildAmazon() && Input.touchCount == 2))
8383
{
8484
if (!consoleMenuInput)
8585
{

0 commit comments

Comments
 (0)