Klicking an a Purebasic Program in KDE

Linux specific forum
User avatar
Brujah
Enthusiast
Enthusiast
Posts: 237
Joined: Mon Nov 03, 2003 7:45 pm
Location: Germany
Contact:

Klicking an a Purebasic Program in KDE

Post by Brujah »

Hy Purebasic Fans,

I want to achieve that when you Klick on my Program File in KDE my game is executed.
Last edited by Brujah on Fri Aug 12, 2005 12:28 am, edited 1 time in total.
User avatar
Brujah
Enthusiast
Enthusiast
Posts: 237
Joined: Mon Nov 03, 2003 7:45 pm
Location: Germany
Contact:

Post by Brujah »

The game runs, but it can't find the other resource files (like my graphics).

Can I read out the path that I got called from?
I have to set this path I think.
And right now I have no idea how to do that.
Beach
Enthusiast
Enthusiast
Posts: 677
Joined: Mon Feb 02, 2004 3:16 am
Location: Beyond the sun...

Post by Beach »

I'm not sure if this would work for you but I use it when I need something out of the environment. Reading 'PWD' gives you the current directory...

BTW: I did not write this code, it is a little to dark for me just yet...

Code: Select all

Procedure.s GetEnv(Variable$)

  Protected *Environ.LONG

  !extrn _environ
  !mov eax, [_environ]
  !mov [esp+4], eax

  Variable$ + "="

  While *Environ\l <> 0
    If CompareMemoryString(@Variable$, *Environ\l, 0, Len(Variable$)) = 0
      ProcedureReturn PeekS(*Environ\l + Len(Variable$))
    EndIf
    *Environ + 4
  Wend

  ProcedureReturn ""

EndProcedure

MessageRequester("test",GetEnv("PWD"))
-Beach
freak
PureBasic Team
PureBasic Team
Posts: 5946
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

You can also use getenv() from the libc, which is probably a bit cleaner:

Code: Select all

Procedure.s GetEnv(Variable$)
  *result = getenv_(Variable$)
  If *result
    ProcedureReturn PeekS(*result)
  Else
    ProcedureReturn ""
  EndIf
EndProcedure
quidquid Latine dictum sit altum videtur
Beach
Enthusiast
Enthusiast
Posts: 677
Joined: Mon Feb 02, 2004 3:16 am
Location: Beyond the sun...

Post by Beach »

Yes, much cleaner! :)
-Beach
User avatar
Brujah
Enthusiast
Enthusiast
Posts: 237
Joined: Mon Nov 03, 2003 7:45 pm
Location: Germany
Contact:

Post by Brujah »

Thanx a lot.
I integerated this routine and when I call my program from
the Commandline its working fine.

But when I click on the File in KDE it seems that thiy Environment Variable "PWD" is not set.

Is there another way to get a KDE Environment Variable?
User avatar
Brujah
Enthusiast
Enthusiast
Posts: 237
Joined: Mon Nov 03, 2003 7:45 pm
Location: Germany
Contact:

Post by Brujah »

I solved the problem in a different way.
I succeeded in creating a rpm for my game.
Now its working fine. Even with a Icon on the Desktop after installation!
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

Brujah wrote:I solved the problem in a different way.
I succeeded in creating a rpm for my game.
Now its working fine. Even with a Icon on the Desktop after installation!
Uh!

Please share on all topics :D
User avatar
Brujah
Enthusiast
Enthusiast
Posts: 237
Joined: Mon Nov 03, 2003 7:45 pm
Location: Germany
Contact:

My Lost Labyrinth Spec

Post by Brujah »

Maybe its useful to anyone.
Here comes the spec that I created for my game.
You create the rpm with it using the command "rpmbuild -ba laby2.spec"

I translated it to 3 languages.


Code: Select all

%define name    laby
%define version 0.9.9
%define release 0

Name:           %{name}
Summary:      Lost Labyrinth is a so-called "roguelike" roleplaying computer game
Summary(de):  Lost Labyrinth ist ein sogenanntes "roguelike"-Computerspiel
Summary(es):  Lost Labyrinth es un Juego para computadoras parecido como el viejo "Roque"
Copyright:      GPL
Group:          Amusements/Games/Other
URL:            http://laby.toybox.de/
Version:        %{version}
Release:        %{release}

Source0:        %{name}_%{version}.tar.gz

Packager:       Markus <mar_doe@gmx.de>
BuildRoot:      /var/tmp/%{name}-%{version}-%{release}
Autoreqprov:    On

%description
Lost Labyrinth is a so-called "roguelike" roleplaying computer game. Lost
Labyrinth has the following features:

* relatively short gameplay (about 10-20 minutes)
* very high replayability; nearly everything in the game is randomly generated
* Sketelon; a lot of options during the character generation; each character
type requires another strategy to survive
* Multiplayer games on the same machine (up to 4 players)
* "Zelda"-like graphics, sound and animation; smooth scrolling of game screen
* Open Source (GPL)

%description -l de
Lost Labyrinth ist ein sogenanntes "roguelike"-Computerspiel. Lost Labyrinth
bietet (im Vergleich zu ähnlichen Spielen) folgende Features:

* sehr kurze Spieldauer (ca. 10-20 Minuten)
* sehr hoher "Replayability"-Faktor; das Labyrinth wird komplett
zufallsgeneriert
* enorm große Anzahl an Charakteroptionen bei der Erschaffung; jeder Charakter
benötigt eine andere Spieltaktik
* Spiele mit mehreren Spielern an derselben Maschine (bis zu vier Spieler)
* "Zelda"-ähnliche Grafik, Sound & Animationen; weiches Scrolling
* Open Source (GPL)

%description -l es
Lost Labyrinth es un Juego para computadoras parecido como el viejo "Roque". Lost Labyrinth
in cambia tiene esos nuevos funciones:

* dura muy poco tiempo (normalmente 10-20 Minutos)
* el Labirinto es creado totalmente de casualidad
* muchas opciones para crear su personaje; cada personaje necesita una propia estrategia
* juegos con maximo 4 jugadores en la misma maquina 
* Graficas como "zelda", Sonido & Animaciones; suave Scrolling
* Open Source (GPL)

%prep
rm -rf $RPM_BUILD_ROOT

%setup -n %{name}_%{version}

%build
%install
[ "$RPM_BUILD_ROOT" != "/" ] && [ -d $RPM_BUILD_ROOT ] && rm -rf $RPM_BUILD_ROOT;
mkdir -p "$RPM_BUILD_ROOT"/usr/games/%{name}
cp -r ./* "$RPM_BUILD_ROOT"/usr/games/%{name}
chmod 755 "$RPM_BUILD_ROOT"/usr/games/%{name}/laby
chmod 777 "$RPM_BUILD_ROOT"/usr/games/%{name}/highscores.dat

cat << EOF > "$RPM_BUILD_ROOT"/usr/games/%{name}/laby
#!/bin/sh
cd %{_libdir}/laby
killall artsd
./purebasic.exe
EOF

cat << EOF > "$RPM_BUILD_ROOT"%/usr/share/applications/laby.desktop
[Desktop Entry]
Encoding=UTF-8
Name=LostLabyrinth
GenericName=LostLabyrinth
GenericName[de]=LostLabyrinth
Comment=Laby Rulez!
Exec=/usr/games/%{name}/laby
Icon=/usr/games/%{name}/laby.xpm
Type=Application
Categories=Application;Game;RolePlaying;
EOF

%post
cat << EOF > ~/Desktop
[Desktop Entry]
Encoding=UTF-8
Name=LostLabyrinth
GenericName=LostLabyrinth
GenericName[de]=LostLabyrinth
Comment=Laby Rulez!
Exec=/usr/games/%{name}/laby
Icon=/usr/games/%{name}/laby.xpm
Type=Application
Categories=Application;Game;RolePlaying;
EOF

%clean
[ "$RPM_BUILD_ROOT" != "/" ] && [ -d $RPM_BUILD_ROOT ] && rm -rf $RPM_BUILD_ROOT;

%files
%defattr(-, root, root)
/usr/games/%{name}/*

%changelog
* Mon Aug 15 2005 drcux <drcux@freenet.de>
First Build
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

Cool!

But how did you solve the current working directory thing?

The "GetEnv("PWD")" code only works when the app is launched from a shell (has it should, because PWD *is* a shell command)...
User avatar
Brujah
Enthusiast
Enthusiast
Posts: 237
Joined: Mon Nov 03, 2003 7:45 pm
Location: Germany
Contact:

Post by Brujah »

There is a Script "laby" created in /usr/games which changes into the right directory and executes the game.

So you can call the game by typing laby.

And you get a Link in your Start Menu. Should be enough to call the game easily now.
freak
PureBasic Team
PureBasic Team
Posts: 5946
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

Num3: PWD is not a command, it is a environment variable, that is set by the shell.
Thats the reason why it only works there ;)
quidquid Latine dictum sit altum videtur
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

Anyway i really like lost labirint, i play it all the time :roll:

But there seems to be a problem with loading saved games, it always gives me "tempered error" even if i don't touch it!
User avatar
Brujah
Enthusiast
Enthusiast
Posts: 237
Joined: Mon Nov 03, 2003 7:45 pm
Location: Germany
Contact:

Post by Brujah »

So you use the windows version!
I have no idea about this.

Right now my version exists only for linux and I got multiplayer mode too! :-)
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

Can you fix the loading routines for windows?

I got to level 19, died, and when i tried to reload the previous level i always get the error...
Post Reply