Skip to content

Commit

Permalink
Merge pull request #14 from softbie/5-multilanguage-support
Browse files Browse the repository at this point in the history
Добавлена поддержка мультиязычности
  • Loading branch information
13Hz authored Jun 24, 2024
2 parents 1909bd2 + bb23515 commit 4a2dbc7
Show file tree
Hide file tree
Showing 15 changed files with 2,435 additions and 2,403 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
/Characters/
/Graphics/
/Data/
/Photo Album/
/Sound/
/Weapons/
/World/
/.idea/

!/Data/Options.dat

*.bb_bak*
2 changes: 2 additions & 0 deletions Data.bb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Function SaveOptions()
For count=1 To 3
WriteString file,gamName$(count)
Next
WriteInt file,optLanguage
CloseFile(file)
End Function

Expand Down Expand Up @@ -59,6 +60,7 @@ Function LoadOptions()
For count=1 To 3
gamName$(count)=ReadString(file)
Next
optLanguage=ReadInt(file)
CloseFile(file)
End Function

Expand Down
Binary file modified Data/Options.dat
Binary file not shown.
41 changes: 28 additions & 13 deletions Menus.bb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Function Options()
;frame rating
timer=CreateTimer(30)
;MAIN LOOP
foc=10 : oldfoc=foc
foc=11 : oldfoc=foc
go=0 : gotim=0 : keytim=20
While go=0

Expand All @@ -96,9 +96,9 @@ While go=0
If KeyDown(1) Then go=-1
;proceed
If KeyDown(28) Or ButtonPressed()
If foc<8 Then foc=10 : keytim=10
If foc=>8 And foc=<9 Then go=1
If foc=10 And keytim=0 Then go=-1
If foc<9 Then foc=11 : keytim=11
If foc=>9 And foc=<10 Then go=1
If foc=11 And keytim=0 Then go=-1
EndIf
EndIf

Expand All @@ -107,8 +107,8 @@ While go=0
;highlight options
If KeyDown(200) Or JoyYDir()=-1 Then foc=foc-1 : PlaySound sMenuSelect : keytim=6
If KeyDown(208) Or JoyYDir()=1 Then foc=foc+1 : PlaySound sMenuSelect : keytim=6
If foc<1 Then foc=10
If foc>10 Then foc=1
If foc<1 Then foc=11
If foc>11 Then foc=1
;browse left
If KeyDown(203) Or JoyXDir()=-1
If foc=1
Expand All @@ -129,6 +129,13 @@ While go=0
If foc=5 Then optShadows=optShadows-1 : PlaySound sMenuBrowse : keytim=6
If foc=6 Then optFX=optFX-1 : PlaySound sMenuBrowse : keytim=6
If foc=7 Then optGore=optGore-1 : PlaySound sMenuBrowse : keytim=6
If foc=8
optLanguage=optLanguage-1
If optLanguage<0 Then optLanguage=1
SaveOptions()
PlaySound sMenuBrowse
keytim=6
EndIf
EndIf
;browse right
If KeyDown(205) Or JoyXDir()=1
Expand All @@ -150,6 +157,13 @@ While go=0
If foc=5 Then optShadows=optShadows+1 : PlaySound sMenuBrowse : keytim=6
If foc=6 Then optFX=optFX+1 : PlaySound sMenuBrowse : keytim=6
If foc=7 Then optGore=optGore+1 : PlaySound sMenuBrowse : keytim=6
If foc=8
optLanguage=optLanguage+1
If optLanguage>1 Then optLanguage=0
SaveOptions()
PlaySound sMenuBrowse
keytim=6
EndIf
EndIf
EndIf
;check limits
Expand Down Expand Up @@ -181,9 +195,10 @@ While go=0
DrawOption(5,rX#(400),rY#(y),translate("Shadows"),textShadows$(optShadows)) : y=y+spacer
DrawOption(6,rX#(400),rY#(y),translate("Particle FX"),textFX$(optFX)) : y=y+spacer
DrawOption(7,rX#(400),rY#(y),translate("Gore"),textGore$(optGore)) : y=y+(spacer+5)
DrawOption(8,rX#(400),rY#(y),translate("REDEFINE KEYS"),"") : y=y+spacer
DrawOption(9,rX#(400),rY#(y),translate("REDEFINE GAMEPAD"),"") : y=y+(spacer+5)
DrawOption(10,rX#(400),rY#(y),translate("<<< BACK <<<"),"")
DrawOption(8,rX#(400),rY#(y),translate("Language"),translate(textLanguages$(optLanguage))) : y=y+(spacer+5)
DrawOption(9,rX#(400),rY#(y),translate("REDEFINE KEYS"),"") : y=y+spacer
DrawOption(10,rX#(400),rY#(y),translate("REDEFINE GAMEPAD"),"") : y=y+(spacer+5)
DrawOption(11,rX#(400),rY#(y),translate("<<< BACK <<<"),"")

Flip
;screenshot (F12)
Expand All @@ -194,9 +209,9 @@ Wend
FreeTimer timer
If go=1 Then PlaySound sMenuGo Else PlaySound sMenuBack
If go=1
If foc=8 Then screen=3
If foc=9 Then screen=4
If foc=10 Then screen=1
If foc=9 Then screen=3
If foc=10 Then screen=4
If foc=11 Then screen=1
EndIf
If go=-1 Then screen=1
End Function
Expand Down Expand Up @@ -595,7 +610,7 @@ Function DrawMainLogo(x#,y#)
;version ID
SetFont font(1)
Outline(translate("Version #FIRST#", "1." + version),x#+310,y#+60,200,200,200,200,200,200)
Outline(translate("Mod #FIRST#", "1.0.4"),x#+310,y#+80,200,200,200,200,200,200)
Outline("Rebirth " + rVersion,x#+310,y#+80,200,200,200,200,200,200)
End Function

;DRAW MENU ITEM
Expand Down
4 changes: 4 additions & 0 deletions Texts.bb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ Key$(203)="Cursor Left" : Key$(205)="Cursor Right"
;//////////////////////////////////////////////////////
;-------------------- STATUS --------------------------
;//////////////////////////////////////////////////////
;languages
Dim textLanguages$(2)
textLanguages$(0)=translate("English")
textLanguages$(1)=translate("Russian")
;weeks
Dim textWeek$(4)
textWeek$(1)=translate("1st week")
Expand Down
2 changes: 2 additions & 0 deletions Values.bb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
;------------------ STRUCTURE -------------------------
;//////////////////////////////////////////////////////
Global version=4
Global rVersion$="1.0.5"
Global screen,oldScreen
Global screenSource,screenAgenda
Global screenCall,callX,callY
Expand Down Expand Up @@ -78,6 +79,7 @@ Global optWeapLim=100
Global optPopulation=60
;preferences
Global optWindowed=0
Global optLanguage=0
Global optRes=2,optFog=1
Global optFX=1,optShadows=2
Global optGore=3 ;0=none, 1=scars, 2=pools, 3=limbs
Expand Down
2 changes: 1 addition & 1 deletion translate_plugin/Main.bb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Global messagesCount = 1582
Global messagesCount = 1584
Dim messages$(messagesCount, 2)

Include "translate_plugin/lang/Others.bb"
Expand Down
2 changes: 1 addition & 1 deletion translate_plugin/Translate.bb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ End Function
; Возвращает переведенную или оригинальную строку
Function translate$(title$, firstReplace$ = "", secondReplace$ = "", thirdReplace$ = "")
For i = 0 To messagesCount
If title$ = messages$(i, 0) Then Return replacement$(messages$(i, 1), firstReplace$, secondReplace$, thirdReplace$)
If title$ = messages$(i, 0) Then Return replacement$(messages$(i, optLanguage), firstReplace$, secondReplace$, thirdReplace$)
Next
Return replacement$(title$, firstReplace$, secondReplace$, thirdReplace$)
End Function
Loading

0 comments on commit 4a2dbc7

Please sign in to comment.