taiko-web development has returned to GitHub. This Gitea instance will be shut down soon.
If your taiko-web fork is unavailable due to DMCA takedown, you can contact GitHub Support and ask for it to be deleted.
Browse Source

Merge branch 'songselect-translatable-song-titles' of LoveEevee/taiko-web into master

Bui 8 months ago
parent
commit
b0f7f68581

+ 4
- 5
app.py View File

@@ -166,7 +166,7 @@ def route_api_songs():
166 166
     categories = {}
167 167
     def_category = {'title': None, 'title_en': None}
168 168
     for cat in raw_categories:
169
-        categories[cat[0]] = {'title': cat[1], 'title_en': cat[2]}
169
+        categories[cat[0]] = cat[1]
170 170
     
171 171
     raw_song_skins = query_db('select * from song_skins')
172 172
     song_skins = {}
@@ -185,15 +185,14 @@ def route_api_songs():
185 185
         songs_out.append({
186 186
             'id': song_id,
187 187
             'title': song[1],
188
-            'title_en': song[2],
188
+            'title_lang': song[2],
189 189
             'subtitle': song[3],
190
-            'subtitle_en': song[4],
190
+            'subtitle_lang': song[4],
191 191
             'stars': [
192 192
                 song[5], song[6], song[7], song[8], song[9]
193 193
             ],
194 194
             'preview': preview,
195
-            'category': category_out['title'],
196
-            'category_en': category_out['title_en'],
195
+            'category': category_out,
197 196
             'type': song_type,
198 197
             'offset': song[13],
199 198
             'song_skin': song_skin_out

+ 5
- 1
public/src/css/songbg.css View File

@@ -33,7 +33,8 @@
33 33
 	max-height: calc(50% + 24vw);
34 34
 }
35 35
 .touchp2 #songbg{
36
-	height: calc(50% - 5.5vw);
36
+	height: calc(50% - 5.9vw);
37
+	min-height: 39.5%;
37 38
 }
38 39
 .multiplayer.portrait #songbg{
39 40
 	height: calc(50% - 37vw);
@@ -89,6 +90,9 @@
89 90
 	height: calc(50% - 13.7vw);
90 91
 	min-height: 25.6%;
91 92
 }
93
+.multiplayer .donbg{
94
+	min-height: 27.2%;
95
+}
92 96
 .portrait .donbg{
93 97
 	height: calc(50% - 48.9vw);
94 98
 	min-height: 22.5%;

+ 10
- 5
public/src/js/about.js View File

@@ -11,7 +11,7 @@
11 11
 		if(touchEnabled){
12 12
 			this.tutorialOuter.classList.add("touch-enabled")
13 13
 		}
14
-		this.linkGithub = document.getElementById("link-github")
14
+		this.linkIssues = document.getElementById("link-issues")
15 15
 		this.linkEmail = document.getElementById("link-email")
16 16
 		
17 17
 		var tutorialTitle = document.getElementById("tutorial-title")
@@ -29,7 +29,13 @@
29 29
 		this.endButton.innerText = strings.tutorial.ok
30 30
 		this.endButton.setAttribute("alt", strings.tutorial.ok)
31 31
 		
32
-		pageEvents.add(this.linkGithub, ["click", "touchend"], this.linkButton.bind(this))
32
+		var versionUrl = "https://github.com/bui/taiko-web/"
33
+		if(gameConfig._version){
34
+			versionUrl = gameConfig._version.url
35
+		}
36
+		this.getLink(this.linkIssues).href = versionUrl + "issues"
37
+		
38
+		pageEvents.add(this.linkIssues, ["click", "touchend"], this.linkButton.bind(this))
33 39
 		pageEvents.add(this.linkEmail, ["click", "touchend"], this.linkButton.bind(this))
34 40
 		pageEvents.once(this.endButton, ["mousedown", "touchstart"]).then(this.onEnd.bind(this))
35 41
 		pageEvents.keyOnce(this, 13, "down").then(this.onEnd.bind(this))
@@ -141,7 +147,6 @@
141 147
 		}
142 148
 		
143 149
 		var issueBody = strings.issueTemplate + "\n\n\n\n" + diag
144
-		this.getLink(this.linkGithub).href += "?body=" + encodeURIComponent(issueBody)
145 150
 		this.getLink(this.linkEmail).href += "?body=" + encodeURIComponent(issueBody.replace(/\n/g, "<br>\r\n"))
146 151
 	}
147 152
 	getLink(target){
@@ -153,7 +158,7 @@
153 158
 	clean(){
154 159
 		cancelTouch = true
155 160
 		this.gamepad.clean()
156
-		pageEvents.remove(this.linkGithub, ["click", "touchend"])
161
+		pageEvents.remove(this.linkIssues, ["click", "touchend"])
157 162
 		pageEvents.remove(this.linkEmail, ["click", "touchend"])
158 163
 		pageEvents.remove(this.endButton, ["mousedown", "touchstart"])
159 164
 		if(this.textarea){
@@ -164,7 +169,7 @@
164 169
 		delete this.diagTxt
165 170
 		delete this.version
166 171
 		delete this.tutorialOuter
167
-		delete this.linkGithub
172
+		delete this.linkIssues
168 173
 		delete this.linkEmail
169 174
 		delete this.textarea
170 175
 	}

+ 18
- 9
public/src/js/controller.js View File

@@ -32,13 +32,15 @@ class Controller{
32 32
 		this.playedSounds = {}
33 33
 	}
34 34
 	run(syncWith){
35
+		if(syncWith){
36
+			this.syncWith = syncWith
37
+		}
35 38
 		this.game.run()
36 39
 		this.view.run()
37
-		if(syncWith){
38
-			syncWith.run()
40
+		if(this.multiplayer === 1){
41
+			syncWith.run(this)
39 42
 			syncWith.game.elapsedTime = this.game.elapsedTime
40 43
 			syncWith.game.startDate = this.game.startDate
41
-			this.syncWith = syncWith
42 44
 		}
43 45
 		requestAnimationFrame(() => {
44 46
 			this.startMainLoop()
@@ -54,16 +56,20 @@ class Controller{
54 56
 		this.mainLoopRunning = true
55 57
 		this.gameLoop()
56 58
 		this.viewLoop()
57
-		this.gameInterval = setInterval(this.gameLoop.bind(this), 1000 / 60)
59
+		if(this.multiplayer !== 2){
60
+			this.gameInterval = setInterval(this.gameLoop.bind(this), 1000 / 60)
61
+		}
58 62
 	}
59 63
 	stopMainLoop(){
60 64
 		this.mainLoopRunning = false
61 65
 		this.mainAsset.stop()
62
-		clearInterval(this.gameInterval)
66
+		if(this.multiplayer !== 2){
67
+			clearInterval(this.gameInterval)
68
+		}
63 69
 	}
64 70
 	gameLoop(){
65 71
 		if(this.mainLoopRunning){
66
-			if(this.syncWith){
72
+			if(this.multiplayer === 1){
67 73
 				this.syncWith.game.elapsedTime = this.game.elapsedTime
68 74
 				this.syncWith.game.startDate = this.game.startDate
69 75
 			}
@@ -83,6 +89,9 @@ class Controller{
83 89
 					this.game.playMainMusic()
84 90
 				}
85 91
 			}
92
+			if(this.multiplayer === 1){
93
+				this.syncWith.gameLoop()
94
+			}
86 95
 		}
87 96
 	}
88 97
 	viewLoop(){
@@ -90,7 +99,7 @@ class Controller{
90 99
 			if(this.multiplayer !== 2){
91 100
 				requestAnimationFrame(() => {
92 101
 					this.viewLoop()
93
-					if(this.syncWith){
102
+					if(this.multiplayer === 1){
94 103
 						this.syncWith.viewLoop()
95 104
 					}
96 105
 					if(this.scoresheet){
@@ -161,7 +170,7 @@ class Controller{
161 170
 		this.playSound(soundID + meka, time)
162 171
 	}
163 172
 	togglePause(){
164
-		if(this.syncWith){
173
+		if(this.multiplayer === 1){
165 174
 			this.syncWith.game.togglePause()
166 175
 		}
167 176
 		this.game.togglePause()
@@ -207,7 +216,7 @@ class Controller{
207 216
 		}
208 217
 	}
209 218
 	clean(){
210
-		if(this.syncWith){
219
+		if(this.multiplayer === 1){
211 220
 			this.syncWith.clean()
212 221
 		}
213 222
 		this.stopMainLoop()

+ 7
- 1
public/src/js/game.js View File

@@ -43,6 +43,12 @@ class Game{
43 43
 	initTiming(){
44 44
 		// Date when the chrono is started (before the game begins)
45 45
 		var offsetTime = Math.max(0, this.timeForDistanceCircle - this.songData.circles[0].ms) |0
46
+		if(this.controller.multiplayer){
47
+			var syncWith = this.controller.syncWith
48
+			var syncCircles = syncWith.game.songData.circles
49
+			var syncOffsetTime = Math.max(0, this.timeForDistanceCircle - syncCircles[0].ms) |0
50
+			offsetTime = Math.max(offsetTime, syncOffsetTime)
51
+		}
46 52
 		this.elapsedTime = -offsetTime
47 53
 		// The real start for the game will start when chrono will reach 0
48 54
 		this.startDate = Date.now() + offsetTime
@@ -320,7 +326,7 @@ class Game{
320 326
 				this.musicFadeOut++
321 327
 			}else if(this.musicFadeOut === 1 && ms >= started + 1600){
322 328
 				this.controller.gameEnded()
323
-				if(!p2.session){
329
+				if(!p2.session && this.controller.multiplayer === 1){
324 330
 					p2.send("gameend")
325 331
 				}
326 332
 				this.musicFadeOut++

+ 6
- 16
public/src/js/importsongs.js View File

@@ -35,33 +35,23 @@
35 35
 			"ura": 4
36 36
 		}
37 37
 		this.categories = {
38
-			"j-pop": "J-POP",
39
-			"pop": "J-POP",
40
-			"アニメ": "アニメ",
41
-			"anime": "アニメ",
42
-			"アニメ": "アニメ",
43
-			"ボーカロイド™曲": "ボーカロイド™曲",
44 38
 			"ボーカロイド曲": "ボーカロイド™曲",
45 39
 			"ボーカロイド": "ボーカロイド™曲",
46
-			"vocaloid™ music": "ボーカロイド™曲",
47 40
 			"vocaloid music": "ボーカロイド™曲",
48 41
 			"vocaloid": "ボーカロイド™曲",
49
-			"バラエティ": "バラエティ",
50 42
 			"バラエティー": "バラエティ",
51 43
 			"どうよう": "バラエティ",
52 44
 			"童謡・民謡": "バラエティ",
53
-			"variety": "バラエティ",
54 45
 			"children": "バラエティ",
55 46
 			"children/folk": "バラエティ",
56 47
 			"children-folk": "バラエティ",
57
-			"クラシック": "クラシック",
58 48
 			"クラッシック": "クラシック",
59
-			"classical": "クラシック",
60
-			"classic": "クラシック",
61
-			"ゲームミュージック": "ゲームミュージック",
62
-			"game music": "ゲームミュージック",
63
-			"ナムコオリジナル": "ナムコオリジナル",
64
-			"namco original": "ナムコオリジナル"
49
+			"classic": "クラシック"
50
+		}
51
+		for(var i in allStrings){
52
+			for(var ja in allStrings[i].categories){
53
+				this.categories[allStrings[i].categories[ja].toLowerCase()] = ja
54
+			}
65 55
 		}
66 56
 		
67 57
 		for(var i = 0; i < files.length; i++){

+ 23
- 6
public/src/js/songselect.js View File

@@ -94,11 +94,12 @@ class SongSelect{
94 94
 		
95 95
 		this.songs = []
96 96
 		for(let song of assets.songs){
97
-			var en = strings.id === "en" && song.title_en
97
+			var title = this.getLocalTitle(song.title, song.title_lang)
98
+			var subtitle = this.getLocalTitle(title === song.title ? song.subtitle : "", song.subtitle_lang)
98 99
 			this.songs.push({
99 100
 				id: song.id,
100
-				title: en ? song.title_en : song.title,
101
-				subtitle: en ? song.subtitle_en : song.subtitle,
101
+				title: title,
102
+				subtitle: subtitle,
102 103
 				skin: song.category in this.songSkin ? this.songSkin[song.category] : this.songSkin.default,
103 104
 				stars: song.stars,
104 105
 				category: song.category,
@@ -1325,7 +1326,7 @@ class SongSelect{
1325 1326
 						if(this.selectedDiff === 4 + this.diffOptions.length){
1326 1327
 							currentDiff = 3
1327 1328
 						}
1328
-						if(i === currentSong.p2Cursor){
1329
+						if(i === currentSong.p2Cursor && p2.socket.readyState === 1){
1329 1330
 							this.draw.diffCursor({
1330 1331
 								ctx: ctx,
1331 1332
 								font: this.font,
@@ -1349,7 +1350,7 @@ class SongSelect{
1349 1350
 									font: this.font,
1350 1351
 									x: _x,
1351 1352
 									y: _y - 65,
1352
-									side: currentSong.p2Cursor === currentDiff
1353
+									side: currentSong.p2Cursor === currentDiff && p2.socket.readyState === 1
1353 1354
 								})
1354 1355
 							}
1355 1356
 							if(highlight){
@@ -1664,7 +1665,7 @@ class SongSelect{
1664 1665
 			})
1665 1666
 		}
1666 1667
 		this.draw.songFrame(config)
1667
-		if(config.song.p2Cursor){
1668
+		if(config.song.p2Cursor && p2.socket.readyState === 1){
1668 1669
 			this.draw.diffCursor({
1669 1670
 				ctx: ctx,
1670 1671
 				font: this.font,
@@ -1853,6 +1854,22 @@ class SongSelect{
1853 1854
 		return ((index % length) + length) % length
1854 1855
 	}
1855 1856
 	
1857
+	getLocalTitle(title, titleLang){
1858
+		if(titleLang){
1859
+			titleLang = titleLang.split("\n")
1860
+			titleLang.forEach(line => {
1861
+				var space = line.indexOf(" ")
1862
+				var id = line.slice(0, space)
1863
+				if(id === strings.id){
1864
+					title = line.slice(space + 1)
1865
+				}else if(titleLang.length === 1 && strings.id === "en" && !(id in allStrings)){
1866
+					title = line
1867
+				}
1868
+			})
1869
+		}
1870
+		return title
1871
+	}
1872
+	
1856 1873
 	getMS(){
1857 1874
 		return Date.now()
1858 1875
 	}

+ 5
- 5
public/src/js/strings.js View File

@@ -78,7 +78,7 @@
78 78
 		bugReporting: [
79 79
 			"このシミュレータは現在開発中です。",
80 80
 			"バグが発生した場合は、報告してください。",
81
-			"GitHubかメールでバグを報告してください。"
81
+			"Gitリポジトリかメールでバグを報告してください。"
82 82
 		],
83 83
 		diagnosticWarning: "以下の端末診断情報も併せて報告してください!",
84 84
 		issueTemplate: "###### 下記の問題を説明してください。 スクリーンショットと診断情報を含めてください。"
@@ -169,7 +169,7 @@ function StringsEn(){
169 169
 		bugReporting: [
170 170
 			"This simulator is still in development.",
171 171
 			"Please report any bugs you find.",
172
-			"You can report bugs either via GitHub or email."
172
+			"You can report bugs either via our Git repository or email."
173 173
 		],
174 174
 		diagnosticWarning: "Be sure to include the following diagnostic data!",
175 175
 		issueTemplate: "###### Describe the problem you are having below. Please include a screenshot and the diagnostic information."
@@ -260,7 +260,7 @@ function StringsCn(){
260 260
 		bugReporting: [
261 261
 			"This simulator is still in development.",
262 262
 			"Please report any bugs you find.",
263
-			"You can report bugs either via GitHub or email."
263
+			"You can report bugs either via our Git repository or email."
264 264
 		],
265 265
 		diagnosticWarning: "Be sure to include the following diagnostic data!",
266 266
 		issueTemplate: "###### Describe the problem you are having below. Please include a screenshot and the diagnostic information."
@@ -351,7 +351,7 @@ function StringsTw(){
351 351
 		bugReporting: [
352 352
 			"This simulator is still in development.",
353 353
 			"Please report any bugs you find.",
354
-			"You can report bugs either via GitHub or email."
354
+			"You can report bugs either via our Git repository or email."
355 355
 		],
356 356
 		diagnosticWarning: "Be sure to include the following diagnostic data!",
357 357
 		issueTemplate: "###### Describe the problem you are having below. Please include a screenshot and the diagnostic information."
@@ -442,7 +442,7 @@ function StringsKo(){
442 442
 		bugReporting: [
443 443
 			"This simulator is still in development.",
444 444
 			"Please report any bugs you find.",
445
-			"You can report bugs either via GitHub or email."
445
+			"You can report bugs either via our Git repository or email."
446 446
 		],
447 447
 		diagnosticWarning: "Be sure to include the following diagnostic data!",
448 448
 		issueTemplate: "###### Describe the problem you are having below. Please include a screenshot and the diagnostic information."

+ 1
- 1
public/src/js/view.js View File

@@ -220,7 +220,7 @@
220 220
 		
221 221
 		this.drawGogoTime()
222 222
 		
223
-		if(!touchMultiplayer){
223
+		if(!touchMultiplayer || this.multiplayer === 1 && frameTop >= 0){
224 224
 			this.assets.drawAssets("background")
225 225
 		}
226 226
 		

+ 2
- 2
public/src/views/about.html View File

@@ -4,8 +4,8 @@
4 4
 		<div id="tutorial-content"></div>
5 5
 		<div id="diag-txt"></div>
6 6
 		<div id="about-link-btns">
7
-			<div id="link-github" class="taibtn stroke-sub link-btn" alt="GitHub">
8
-				<a href="https://github.com/bui/taiko-web/issues/new" target="_blank">GitHub</a>
7
+			<div id="link-issues" class="taibtn stroke-sub link-btn" alt="Issues">
8
+				<a target="_blank">Issues</a>
9 9
 			</div>
10 10
 			<div id="link-email" class="taibtn stroke-sub link-btn" alt="[email protected]">
11 11
 				<a href="mailto:[email protected]">[email protected]</a>

+ 1
- 1
templates/index.html View File

@@ -23,7 +23,7 @@
23 23
 	<div id="screen" class="pattern-bg"></div>
24 24
 	<div id="version">
25 25
 		{% if version %}
26
-			<a href="https://github.com/bui/taiko-web/commit/{{version.commit}}" target="_blank" id="version-link" class="stroke-sub" alt="taiko-web ver.{{version.version}} ({{version.commit_short}})">taiko-web ver.{{version.version}} ({{version.commit_short}})</a>
26
+			<a href="{{version.url}}commit/{{version.commit}}" target="_blank" id="version-link" class="stroke-sub" alt="taiko-web ver.{{version.version}} ({{version.commit_short}})">taiko-web ver.{{version.version}} ({{version.commit_short}})</a>
27 27
 		{% else %}
28 28
 			<a href="https://github.com/bui/taiko-web" target="_blank" id="version-link" class="stroke-sub" alt="taiko-web (unknown version)">taiko-web (unknown version)</a>
29 29
 		{% endif %}

Loading…
Cancel
Save