PureTris !

Advanced game related topics
User avatar
Mindphazer
Enthusiast
Enthusiast
Posts: 456
Joined: Mon Sep 10, 2012 10:41 am
Location: Savoie

Re: PureTris !

Post by Mindphazer »

Small update : translations are now (hopefully) complete
@AJZIO : i have not had time (yet) to look at your code, but I will
MacBook Pro 16" M4 Pro - 24 Gb - MacOS 15.4.1 - Iphone 15 Pro Max - iPad at home
...and unfortunately... Windows at work...
AZJIO
Addict
Addict
Posts: 2141
Joined: Sun May 14, 2017 1:48 am

Re: PureTris !

Post by AZJIO »

Specify an icon in the compiler settings (Windows), then it will also be displayed in Explorer as a file icon.
Delete this line

Code: Select all

SendMessage_(WindowID(#MainWindow), #WM_SETICON, 0, ImageID(PureTrisIco))
For Linux

Code: Select all

CompilerIf #PB_Compiler_OS = #PB_OS_Linux
UseGIFImageDecoder()
DataSection
		IconTitle:
		IncludeBinary "icon.gif"
		IconTitleend:
EndDataSection
CatchImage(0, ?IconTitle)
CompilerEndIf


hGUI = OpenWindow(#Window, 0, 0, 111, 111, "example",  #PB_Window_SystemMenu)
If hGUI
	CompilerIf #PB_Compiler_OS = #PB_OS_Linux
		gtk_window_set_icon_(hGUI, ImageID(0)) ; assign an icon to the title
	CompilerEndIf
AZJIO
Addict
Addict
Posts: 2141
Joined: Sun May 14, 2017 1:48 am

Re: PureTris !

Post by AZJIO »

And it is better that the texts are not inside the program, but outside

Code: Select all

Global  PathLang$

; Specifies the language of the OS
CompilerSelect #PB_Compiler_OS
    CompilerCase #PB_OS_Windows
		Global UserIntLang, *Lang
		If OpenLibrary(0, "kernel32.dll")
			*Lang = GetFunction(0, "GetUserDefaultUILanguage")
			If *Lang
				UserIntLang = CallFunctionFast(*Lang)
			EndIf
			CloseLibrary(0)
		EndIf
    CompilerCase #PB_OS_Linux
		Global UserIntLang$
		If ExamineEnvironmentVariables()
		    While NextEnvironmentVariable()
		    	If Left(EnvironmentVariableName(), 4) = "LANG"
; 		    		LANG=ru_RU.UTF-8
; 		    		LANGUAGE=ru
					UserIntLang$ = Left(EnvironmentVariableValue(), 2)
					Break
				EndIf
		    Wend
		EndIf
CompilerEndSelect
; Debug UserIntLang$

#CountStrLang = 2 ; number of translation lines and corresponding array
Global Dim Lng.s(#CountStrLang)
; Interface strings even if the language file is not found (default)
Lng(1) = "Example"
Lng(2) = "Program"


; you can add 2 languages, your own and English, so as not to depend on external files.
CompilerSelect #PB_Compiler_OS
	CompilerCase #PB_OS_Windows
		If UserIntLang = 1049
    CompilerCase #PB_OS_Linux
		If UserIntLang$ = "ru"
CompilerEndSelect

	Lng(1) = "Пример"
	Lng(2) = "Программа"
EndIf

; defines the paths to the language file. In this example, one file is used as the current GUI language
CompilerSelect #PB_Compiler_OS
	CompilerCase #PB_OS_Windows
; 		the file name is the same As the program name "MyProg_Lang.txt" (if compiled as MyProg.exe)
; 		PathLang$ = GetPathPart(ProgramFilename()) + GetFilePart(ProgramFilename(), #PB_FileSystem_NoExtension) + "_Lang.txt"
; 		file name by language number, for example 1049.txt, then you can have several languages ​​included with the program
		PathLang$ = GetPathPart(ProgramFilename()) + Str(UserIntLang) + ".txt"
    CompilerCase #PB_OS_Linux
		PathLang$ ="/usr/share/locale/" + UserIntLang$ + "/LC_MESSAGES/" + GetFilePart(ProgramFilename(), #PB_FileSystem_NoExtension) + ".txt"
CompilerEndSelect
; Debug PathLang$

; If the language file exists, use it. Each line contains one of the translations
If FileSize(PathLang$) > 100
	
	If ReadFile(0, PathLang$)
		i=0
	    While Eof(0) = 0        ; The loop is executed until the end of the file is reached. (Eof = 'End of file')
	    	tmp$ =  ReadString(0)
; 	    	If Left(tmp$, 1) = ";" ; skip commented lines
; 	    		Continue
; 	    	EndIf
	    	tmp$ = ReplaceString(tmp$ , #CR$ , "") ; correction if in Windows
	    	If Asc(tmp$) And Left(tmp$, 1) <> ";" ; skip commented lines
	    		i+1
	    		If i > #CountStrLang ; the Lng() array is already set, but if there are more lines than necessary, then we do not allow the excess
	    			Break
	    		EndIf
	    		Lng(i) = tmp$
	    	Else
	    		Continue
	    	EndIf
	    Wend
	    CloseFile(0)
	EndIf
; Else
; 	SaveFile_Buff(PathLang$, ?LangFile, ?LangFileend - ?LangFile) ; create an example language file
EndIf
; End => Language detection


If OpenWindow(0, 0, 0, 220, 100, Lng(2), #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
	ButtonGadget (1, 10, 60, 200, 30, Lng(1))

	Repeat
		Select WaitWindowEvent()
			Case #PB_Event_Gadget
				Select EventGadget()
					Case 1
						CloseWindow(0)
						End
				EndSelect
			Case #PB_Event_CloseWindow
				CloseWindow(0)
				End
		EndSelect
	ForEver
EndIf
At you too the map duplicates lines. It's better to use pointers.
User avatar
Mindphazer
Enthusiast
Enthusiast
Posts: 456
Joined: Mon Sep 10, 2012 10:41 am
Location: Savoie

Re: PureTris !

Post by Mindphazer »

AZJIO wrote: Sun Jul 23, 2023 4:14 pm At you too the map duplicates lines. It's better to use pointers.
Mhmmm... pointers are (very) far from being my best friends :mrgreen:
MacBook Pro 16" M4 Pro - 24 Gb - MacOS 15.4.1 - Iphone 15 Pro Max - iPad at home
...and unfortunately... Windows at work...
User avatar
Mindphazer
Enthusiast
Enthusiast
Posts: 456
Joined: Mon Sep 10, 2012 10:41 am
Location: Savoie

Re: PureTris !

Post by Mindphazer »

@AZJIO : i have modified the source according to some of your suggestions. Can you confirm that Russian language is selected ? (and, by the way, can you complete the russian translation ?)
MacBook Pro 16" M4 Pro - 24 Gb - MacOS 15.4.1 - Iphone 15 Pro Max - iPad at home
...and unfortunately... Windows at work...
AZJIO
Addict
Addict
Posts: 2141
Joined: Sun May 14, 2017 1:48 am

Re: PureTris !

Post by AZJIO »

User avatar
Mindphazer
Enthusiast
Enthusiast
Posts: 456
Joined: Mon Sep 10, 2012 10:41 am
Location: Savoie

Re: PureTris !

Post by Mindphazer »

Thanks AZJIO
I'll have a look
MacBook Pro 16" M4 Pro - 24 Gb - MacOS 15.4.1 - Iphone 15 Pro Max - iPad at home
...and unfortunately... Windows at work...
ppaolo80
New User
New User
Posts: 3
Joined: Sat Aug 20, 2022 10:59 am

Re: PureTris !

Post by ppaolo80 »

Hi, where to download "Tetris.pbf". Thanks
User avatar
Janni
Enthusiast
Enthusiast
Posts: 127
Joined: Mon Feb 21, 2022 5:58 pm
Location: Norway

Re: PureTris !

Post by Janni »

ppaolo80 wrote: Wed Aug 23, 2023 9:57 am Hi, where to download "Tetris.pbf". Thanks
Link is in the first post.
Spec: Linux Mint 20.3 Cinnamon, i7-3770K, 16GB RAM, RTX 2070 Super
ppaolo80
New User
New User
Posts: 3
Joined: Sat Aug 20, 2022 10:59 am

Re: PureTris !

Post by ppaolo80 »

Hi, where to download "Tetris.pbf".

I downloaded it from the first post but the Tetris.pbf file is missing.

Thanks
User avatar
jacdelad
Addict
Addict
Posts: 1991
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: PureTris !

Post by jacdelad »

ppaolo80 wrote: Wed Aug 23, 2023 10:09 am Hi, where to download "Tetris.pbf".

I downloaded it from the first post but the Tetris.pbf file is missing.

Thanks
What makes you think you need a Tetris.pbf-file? Have you even once tried to compile it?
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
ppaolo80
New User
New User
Posts: 3
Joined: Sat Aug 20, 2022 10:59 am

Re: PureTris !

Post by ppaolo80 »

Sorry you're right compiling the file is complete, I continued to compile an old version where it asked for the Tetris.pbf file. Anyway thanks.
User avatar
Mindphazer
Enthusiast
Enthusiast
Posts: 456
Joined: Mon Sep 10, 2012 10:41 am
Location: Savoie

Re: PureTris !

Post by Mindphazer »

Indeed, as i've stated here (viewtopic.php?p=603512#p603512), there is no .pbf file anymore
MacBook Pro 16" M4 Pro - 24 Gb - MacOS 15.4.1 - Iphone 15 Pro Max - iPad at home
...and unfortunately... Windows at work...
Roby
New User
New User
Posts: 5
Joined: Fri Feb 09, 2024 9:16 am
Location: Italy

Re: PureTris !

Post by Roby »

Good job, thank you.
Post Reply