Page 5 of 5
Re: PureTris !
Posted: Sun Jul 23, 2023 9:42 am
by Mindphazer
Small update : translations are now (hopefully) complete
@AJZIO : i have not had time (yet) to look at your code, but I will
Re: PureTris !
Posted: Sun Jul 23, 2023 3:22 pm
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
Re: PureTris !
Posted: Sun Jul 23, 2023 4:14 pm
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.
Re: PureTris !
Posted: Sun Jul 23, 2023 5:11 pm
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

Re: PureTris !
Posted: Mon Jul 24, 2023 10:50 am
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 ?)
Re: PureTris !
Posted: Mon Jul 24, 2023 4:21 pm
by AZJIO
Re: PureTris !
Posted: Wed Jul 26, 2023 7:48 am
by Mindphazer
Thanks AZJIO
I'll have a look
Re: PureTris !
Posted: Wed Aug 23, 2023 9:57 am
by ppaolo80
Hi, where to download "Tetris.pbf". Thanks
Re: PureTris !
Posted: Wed Aug 23, 2023 10:00 am
by Janni
ppaolo80 wrote: Wed Aug 23, 2023 9:57 am
Hi, where to download "Tetris.pbf". Thanks
Link is in the first post.
Re: PureTris !
Posted: Wed Aug 23, 2023 10:09 am
by ppaolo80
Hi, where to download "Tetris.pbf".
I downloaded it from the first post but the Tetris.pbf file is missing.
Thanks
Re: PureTris !
Posted: Wed Aug 23, 2023 1:20 pm
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?
Re: PureTris !
Posted: Thu Aug 24, 2023 9:31 am
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.
Re: PureTris !
Posted: Wed Aug 30, 2023 8:12 pm
by Mindphazer
Indeed, as i've stated here (
viewtopic.php?p=603512#p603512), there is no .pbf file anymore
Re: PureTris !
Posted: Sun Dec 08, 2024 4:05 pm
by Roby
Good job, thank you.