*.dsc
src/build-stamp
src/mancala
+src/launcher/mancala-launcher
+src/plugin/mancala-ui-plugin.o
+src/plugin/mancala-ui-plugin.so
build-stamp
debian/docs
debian/maemo-mancala/
mkdir -p $(DESTDIR)/usr/share/applications/hildon
mkdir -p $(DESTDIR)/usr/share/icons/hicolor/40x40/apps
mkdir -p $(DESTDIR)/usr/share/dbus-1/services
+ mkdir -p $(DESTDIR)/home/opt/mancala/data/
+ mkdir -p $(DESTDIR)/home/opt/mancala/bin/
cp data/mancala.desktop $(DESTDIR)/usr/share/applications/hildon
cp data/mancala.png $(DESTDIR)/usr/share/icons/hicolor/40x40/apps/mancala.png
cp data/com.nokia.mancala.service $(DESTDIR)/usr/share/dbus-1/services/
+ cp data/com.nokia.mancala_startup.service $(DESTDIR)/usr/share/dbus-1/services/
+ cp data/mancala.conf $(DESTDIR)/home/opt/mancala/data/
+ cp data/mancala.game $(DESTDIR)/home/opt/mancala/data/
+ cp data/mancala.html $(DESTDIR)/home/opt/mancala/data/
+ cp data/mancala.sh $(DESTDIR)/home/opt/mancala/bin/
clean:
rm -f build-stamp config.guess config.sub
dpkg-buildpackage -rfakeroot -b -us -uc
.PHONY: clobber clean install subsystem maemo-source maemo-bin
-
[D-BUS Service]
Name=com.nokia.mancala
-Exec=/home/opt/mancala/bin/mancala
+Exec=/home/opt/mancala/bin/mancala-launcher
--- /dev/null
+[D-BUS Service]
+Name=com.nokia.mancala_startup
+Exec=/home/opt/mancala/bin/mancala.sh
--- /dev/null
+[Startup Entry]
+# the name of the application
+Name=mancala
+# the current version of the application
+Version=0.2
+# the title that is used, if not specified by the GettextPackage
+Title=Mancala
+# the GettextPackage to be used to locate the title string
+GettextPackage=mancala
+# if the TitleId is defined, it searches for it inside the gettext package
+# TitleId=example_title
+# if the game has a plug-in
+PluginPath=/home/opt/mancala/plugin/mancala-ui-plugin.so
+# the games-startup screen image
+Image=/home/opt/mancala/data/mancala.png
+# the D-BUS service, path and interface names
+ServiceName=com.nokia.mancala
+PathName=/com/nokia/mancala
+InterfaceName=com.nokia.mancala
+
[Desktop Entry]
Encoding=UTF-8
-Version=0.1
+Version=0.2
Name=Mancala
Comment=Mancala game for Maemo devices
-Exec=/home/opt/mancala/bin/mancala
+Exec=/home/opt/mancala/bin/mancala.sh
Icon=mancala
-Terminal=false
Type=Application
Categories=Games
X-HildonDesk-ShowInToolbar=true
-X-Osso-Type=application/x-executable
X-Window-Icon=mancala
-X-Osso-Service=com.nokia.mancala
-
-
+X-Osso-Service=com.nokia.mancala_startup
\ No newline at end of file
--- /dev/null
+mancala
+/home/opt/mancala/bin/mancala
+com.nokia.mancala
+/com/nokia/mancala
+com.nokia.mancala
+0.2
+
--- /dev/null
+<!--
+*
+* This file is part of Mancala
+*
+* Copyright (c) 2009 Reto Zingg
+* Text from cmancala game:
+* http://sourceforge.net/projects/cmancala/files/mancala-text/mancala-0.2.1/mancala-0.2.1.tar.gz/download
+*
+* This software is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public License
+* as published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA
+-->
+<html>
+<head></head>
+<body>
+<h1>Welcome to Mancala, the ancient African game of skill!</h1>
+<p><big>Mancala is a very simple, easy-to-learn game. Each player begins with a horizontal row of holes or pits filled with a certain number of stones. At either end of the board are the players' home pits, which are used to keep score. In this case, the human player has the left home pit and the upper row holes. A move is made by clicking into the hole you wish to move from. The stones are then picked up and distributed, one to each hole, moving toward your home pit is reached, and then moving through your opponent's row, bypassing his/her home, and moving back towards in a circle (counterclockwise), until all the stones have been distributed.</big></p>
+<p><big>If the last stone is placed in your home, you receive an extra turn. If the last stone lands in an empty hole on your side, you 'capture' the stones in the opposite hole on your opponent's side, moving them to your home.</big></p>
+<p><big>The game ends when one player cannot play (ie. there are no stones on his/her side of the board. The player who has the most stones on his/her *side* wins.</big></p>
+</body>
+</html>
--- /dev/null
+#!/bin/sh
+#
+#
+# This file is part of Mancala
+#
+# Copyright (C) 2009 Reto Zingg
+#
+# Some of the code is based on the examples on:
+# http://wiki.maemo.org/Documentation/Maemo_5_Developer_Guide
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2, or (at your option) any
+# later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details, a copy of which may be found in
+# the file COPYING provided in the main directory of this release.
+#
+
+/usr/bin/osso_games_startup /home/opt/mancala/data/mancala.conf
+
+mancala (0.2.0-2) unstable; urgency=low
+
+ * with plugin
+
+ -- Reto Zingg <g.d0b3rm4n@gmail.com> Fri, 25 Dec 2009 18:01:34 +0200
+
+mancala (0.2.0-1) unstable; urgency=low
+
+ * refractoring
+
+ -- Reto Zingg <g.d0b3rm4n@gmail.com> Fri, 25 Dec 2009 13:40:07 +0200
+
mancala (0.1.10-2) unstable; urgency=low
* updated control file
Package: mancala
Architecture: any
Section: user/games
-Depends: ${shlibs:Depends}, ${misc:Depends}
+Depends: ${shlibs:Depends}, ${misc:Depends}, osso-games-startup, hildon-games-wrapper0
Description: Mancala, the ancient African game of skill!
Maemo version of mancala from http://cmancala.sourceforge.net/
Please file bugs here for this maemo version:
Reserved. Luxi is a registered trademark of Bigelow & Holmes Inc.
see COPYRIGHT.BH file.
+
+parts from Crazyparking:
+http://repository.maemo.org/extras-testing/pool/fremantle/free/source/c/crazyparking/crazyparking_0.2.7-2.tar.gz
+License: GNU General Public License Version 2
DBG = gdb
STD = _GNU_SOURCE
CFLAGS = `sdl-config --cflags` -I/usr/local/include/SDL `pkg-config hildon-1 --cflags` -I/usr/include/dbus-1.0/ -I/usr/lib/dbus-1.0/include/
-LFLAGS = `sdl-config --static-libs ` -lSDL_image -lSDL_ttf -lSDL_mixer `pkg-config hildon-1 --libs` `pkg-config --libs libosso`
+LFLAGS = `sdl-config --static-libs ` -lSDL_image -lSDL_ttf -lSDL_mixer `pkg-config hildon-1 --libs` `pkg-config --libs libosso` -lhgw
-MAIN_OBJ = main.o graphics.o mancala.o sounds.o play.o
+# MAIN_OBJ = main.o graphics.o mancala.o sounds.o play.o
+MAIN_OBJ = graphics.o mancala.o sounds.o play.o callbacks.o
TEST_OBJ = ai-test.o mancala.o
NORMAL = ai.o
RECURSE = ai-init.o ai-recurse.o
ULTIMATE = ai-init.o ai-ultimate.o
+subsystem:
+ $(MAKE) -C launcher
+ $(MAKE) -C plugin
+
#'$<' is filename of input, '$@' is filename of output
.c.o:
$(CC) -c -g$(DBG) -Wall $(CFLAGS) -D$(STD) $<
$(CC) -c -g$(DBG) -Wall $(CFLAGS) -D$(STD) $<
all: $(MAIN_OBJ) $(NORMAL)
+ $(MAKE) -C launcher all
+ $(MAKE) -C plugin all
$(CC) $(MAIN_OBJ) $(NORMAL) $(LFLAGS) -o mancala
recurse: $(MAIN_OBJ) $(RECURSE)
cp ../data/*.png $(DESTDIR)/home/opt/mancala/data/
cp ../data/*.wav $(DESTDIR)/home/opt/mancala/data/
cp ../data/*.ttf $(DESTDIR)/home/opt/mancala/data/
+ $(MAKE) -C launcher install
+ $(MAKE) -C plugin install
uninstall:
clean:
rm -f *.o *.core *.swp *~ *.log
+ $(MAKE) -C launcher clean
+ $(MAKE) -C plugin clean
clobber: clean
rm -f mancala ai-test
+ $(MAKE) -C launcher clobber
+ $(MAKE) -C plugin clobber
distclean: clobber
@echo "No configuration files to distclean yet."
--- /dev/null
+/*
+* This file is part of Mancala
+*
+* Originally from Crazyparking:
+*
+* Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia
+* http://www.indt.org/maemo
+*
+* adapted:
+* Copyright (c) 2009 Reto Zingg
+*
+* This software is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public License
+* as published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA
+*
+*/
+#include <stdio.h>
+#include <hgw/hgw.h>
+#include "callbacks.h"
+
+
+// Pause the game
+int exit_callback(int errcode) {
+ printf("exit_callback called...\n");
+ return 0;
+}
+
+// Quit game
+int quit_callback(int errcode) {
+ printf("quit_callback called...\n");
+ hgw_context_compat_destroy_quit(hgw_context);
+ return 0;
+}
+
+int flush_callback(int errcode) {
+ printf("quit_callback called...\n");
+ return 0;
+}
--- /dev/null
+/*
+* This file is part of Mancala
+*
+* Originally from Crazyparking:
+* Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia
+* http://www.indt.org/maemo
+*
+* This software is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public License
+* as published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA
+*
+*/
+extern HgwContext *hgw_context;
+
+int exit_callback(int errcode/*, AppData *app_data*/);
+int quit_callback(int errcode/*, AppData *app_data*/);
+int flush_callback(int errcode);
--- /dev/null
+# GNU Makefile -- Makefile
+# 2009 Reto Zingg
+
+
+CC = gcc
+
+
+all:
+ $(CC) mancala-launcher.c -o mancala-launcher
+
+install: all
+ mkdir -p $(DESTDIR)/home/opt/mancala/bin/
+ cp ./mancala-launcher $(DESTDIR)/home/opt/mancala/bin/mancala-launcher
+
+uninstall:
+ rm -rf $(DESTDIR)/home/opt/mancala/mancala-launcher
+
+clean:
+ rm -f *.o *.core *.swp *~ *.log
+
+clobber: clean
+ rm -f mancala-launcher
+
--- /dev/null
+/*
+* This file is part of Mancala
+*
+* Idea from Crazyparking
+*
+* Copyright (c) 2009 Reto Zingg
+*
+* This software is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public License
+* as published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA
+*/
+
+#include <stdio.h>
+#include <unistd.h>
+
+char *wrapper_args[] = {"/usr/games/wrapper/wrapper",
+ "/home/opt/mancala/data/mancala.game",
+ NULL};
+
+int main(int argc, char *argv[])
+{
+
+ if (execv ("/usr/games/wrapper/wrapper", wrapper_args) == -1) {
+ printf("Launching mancala wrapper failed\n");
+ }
+
+ return 0;
+}
/*
+*
+* This file is part of Mancala
+*
* Copyright (C) 2009 Reto Zingg
*
* Some of the code is based on the examples on:
*
*/
+/*********************************************************************
+**
+** NOT used at the moment...
+**
+*********************************************************************/
+
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
return 0;
}
+
*/
#include <hildon/hildon.h>
+#include <hgw/hgw.h>
+#include <unistd.h>
#include "SDL_mixer.h"
#include "SDL.h"
#include "SDL_image.h"
#include "SDL_ttf.h"
+#include "SDL_getenv.h"
#include "graphics.h"
#include "mancala.h"
#include "sounds.h"
#include "play.h"
+#include "callbacks.h"
+
// the surfaces
SDL_Surface *screen, *board, *title_text, *tile, *stone[STONE_MAX+1], *exit_text;
// the fonts
TTF_Font *title_font, *home_font, *board_font;
// The sound effects that will be used
Mix_Chunk *pick = NULL;
+// the hildon-game-wrapper context
+HgwContext *hgw_context = NULL;
+
+// for debugging, example:
+
+// rmz_debug(g_strdup_printf("play step 2: SDL_AUDIODRIVER: %s",
+// my_sdl_audiodrv)
+// );
+// void rmz_debug (char *msg){
+// FILE *pFile;
+//
+// pFile = fopen ("/home/rzingg/mancala.debug", "a");
+// if (pFile) {
+// fprintf (pFile, "rmz_debug: %s \n", msg);
+// fclose (pFile);
+// }
+// }
void sdl_clean_up(){
}
int play() {
+
+ // Scratchbox needs different SDL_AudiDriver env
+ #if __i386__
+ putenv("SDL_AUDIODRIVER=alsa") ;
+ #endif /* __i386__ */
SDL_Rect board_rect, title_rect, exit_rect;
SDL_Color font_color;
/* initialize our libraries */
//if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER|SDL_INIT_AUDIO) < 0) {
if (SDL_Init(SDL_INIT_EVERYTHING) < 0) {
- fprintf(stderr, "Unable to initialize SDL: %s\n",
+ printf("Unable to initialize SDL: %s\n",
SDL_GetError());
sdl_clean_up();
return 1;
}
if (TTF_Init() < 0) {
- fprintf(stderr, "Unable to initialize SDL_ttf: %s\n",
+ printf("Unable to initialize SDL_ttf: %s\n",
SDL_GetError());
sdl_clean_up();
return 1;
}
//Initialize SDL_mixer
-
if( Mix_OpenAudio( 22050, MIX_DEFAULT_FORMAT, 2, 4096 ) == -1 )
+ // if( Mix_OpenAudio(22050, (Uint16)AUDIO_U8, 2, 256 ) == -1 )
{
- fprintf(stderr, "Unable to initialize Mix_OpenAudio: %s\n",
+ printf("Unable to initialize Mix_OpenAudio: %s\n",
SDL_GetError());
sdl_clean_up();
return 1;
}
-
/* Load our images... PNGs now, maybe XPMs later */
sprintf(tile_path, "%s/tile.png", RES_PATH);
if ((tile = LoadRes(tile_path)) == NULL) {
- fprintf(stderr, "Unable to load resource: %s\n",
+ printf("Unable to load resource: %s\n",
SDL_GetError());
sdl_clean_up();
return 1;
for (i=0; i<=STONE_MAX; i++) {
if (sprintf(stone_path, "%s/stone%02d.png", RES_PATH, i) == 0)
- fprintf(stderr, "Problems assembling path.\n");
+ printf("Problems assembling path.\n");
if (!(stone[i] = LoadRes(stone_path))) {
- fprintf(stderr, "Unable to load resource: %s\n",
+ printf("Unable to load resource: %s\n",
SDL_GetError());
sdl_clean_up();
return 1;
/* Load our font(s) */
if (sprintf(title_path, "%s/luxisr.ttf", FONT_PATH) == 0)
- fprintf(stderr, "Problems assembling path.\n");
+ printf("Problems assembling path.\n");
if (!(title_font = TTF_OpenFont(title_path, TITLE_SIZE))) {
- fprintf(stderr, "Could not load font: %s\n", TTF_GetError());
+ printf("Could not load font: %s\n", TTF_GetError());
sdl_clean_up();
return 1;
}
if (sprintf(board_path, "%s/luxisr.ttf", FONT_PATH) == 0)
- fprintf(stderr, "Problems assembling path.\n");
+ printf("Problems assembling path.\n");
if (!(board_font = TTF_OpenFont(board_path, BOARD_SIZE))) {
- fprintf(stderr, "Could not load font: %s\n", TTF_GetError());
+ printf("Could not load font: %s\n", TTF_GetError());
sdl_clean_up();
return 1;
}
if (sprintf(home_path, "%s/luxisr.ttf", FONT_PATH) == 0)
- fprintf(stderr, "Problems assembling path.\n");
+ printf("Problems assembling path.\n");
if (!(home_font = TTF_OpenFont(home_path, HOME_SIZE))) {
- fprintf(stderr, "Could not load font: %s\n", TTF_GetError());
+ printf("Could not load font: %s\n", TTF_GetError());
sdl_clean_up();
return 1;
}
/* Load sound effects */
sprintf(pick_path, "%s/pick.wav", RES_PATH);
if ((pick = Mix_LoadWAV(pick_path)) == NULL) {
- fprintf(stderr, "Unable to load sound: %s\n",
+ printf("Unable to load sound: %s\n",
SDL_GetError());
sdl_clean_up();
return 1;
/* set window properties and create it */
SDL_WM_SetCaption("Mancala", "Mancala");
if (sprintf(icon_path, "%s/icon.png", RES_PATH) == 0)
- fprintf(stderr, "Problems assembling icon path.\n");
+ printf("Problems assembling icon path.\n");
SDL_WM_SetIcon(LoadRes(icon_path), NULL);
if ((screen = SDL_SetVideoMode(tile->w*8, (tile->h*2) + Y_OFFSET, 16, SDL_FULLSCREEN))
== NULL) {
- fprintf(stderr, "Unable to set %dx%d video: %s", tile->w*8,
+ printf("Unable to set %dx%d video: %s", tile->w*8,
tile->h*2, SDL_GetError());
sdl_clean_up();
return 1;
}
-
+ SDL_ShowCursor(SDL_DISABLE);
/* define the font color fot the exit text */
font_color_exit.r = 255;
font_color_exit.r = 255;
font_color_exit.r = 255;
-
-
if (!(exit_text = TTF_RenderText_Blended(home_font, "EXIT",
font_color_exit))) {
- fprintf(stderr, "SDL_ttf: %s\n", TTF_GetError());
+ printf("SDL_ttf: %s\n", TTF_GetError());
return 1;
}
while (SDL_PollEvent(&event)) {
/* BAIL OUT! BAIL OUT! */
if (event.type == SDL_KEYDOWN){
- fprintf(stderr, "event SDL_KEYDOWN found....\n");
+ printf("event SDL_KEYDOWN found....\n");
if ( event.key.keysym.sym == SDLK_q )
{
- fprintf(stderr, "event SDLK_q found....\n");
+ printf("event SDLK_q found....\n");
SDL_Event quit_event;
quit_event.type = SDL_QUIT;
SDL_PushEvent(&quit_event);
if (event.type == SDL_MOUSEBUTTONDOWN) {
if ((event.button.button = 1) &&
(event.button.y < Y_OFFSET)) {
- fprintf(stderr, "clicked out side the board in exit area...\n");
+ printf("clicked out side the board in exit area...\n");
SDL_Event quit_event;
quit_event.type = SDL_QUIT;
SDL_PushEvent(&quit_event);
}
if (event.type == SDL_QUIT) {
- fprintf(stderr, "event SDL_QUIT found....\n");
+ printf("event SDL_QUIT found....\n");
sdl_clean_up();
return 0;
}
// pitch 0 and 7 are the homebases which you can't play
if ( pitch == 0 || pitch == 7 ){
- fprintf(stderr, "clicked out side the board...\n");
+ printf("clicked out side the board...\n");
}
else{
current_move = pitch;
if (aiBoard[0] > humanBoard[0]) {
if (!(title_text = TTF_RenderText_Blended(title_font,
"Computer Wins!", font_color)))
- fprintf(stderr, "TTF: %s\n", TTF_GetError());
+ printf("TTF: %s\n", TTF_GetError());
}
else {
if (!(title_text = TTF_RenderText_Blended(title_font,
"Human Wins!", font_color)))
- fprintf(stderr, "TTF: %s\n", TTF_GetError());
+ printf("TTF: %s\n", TTF_GetError());
}
redraw_board = 1;
break;
home_font, tile, stone, active,
highlight);
if (!board) {
- fprintf(stderr, "Could not draw the board.\n");
+ printf("Could not draw the board.\n");
}
else {
// board_rect = SurfaceToRect(board);
redraw_board = 0;
}
+ hgw_msg_compat_receive(hgw_context, 0);
+
}
SDL_Delay(DELAY_AI);
+
sdl_clean_up();
return 0;
}
+
+int main(int argc, char **argv) {
+
+ hgw_context = hgw_context_compat_init(argc, argv);
+ if (!hgw_context) {
+ printf("Cannot init hildon-games-startup!\n");
+ return 0;
+ }
+
+ hgw_compat_set_cb_exit(hgw_context, exit_callback);
+ hgw_compat_set_cb_quit(hgw_context, quit_callback);
+ hgw_compat_set_cb_flush(hgw_context, flush_callback);
+ if(!hgw_context_compat_check(hgw_context)) return 0;
+
+ /* hildon-games-wrapper part */
+ hgw_msg_compat_receive(hgw_context, 0);
+ usleep(100);
+
+ // Main game
+ play();
+
+ // hgw_context_compat_destroy_deinit(hgw_context);
+ // hgw_context_compat_destroy_quit(hgw_context);
+ hgw_context_destroy(hgw_context);
+
+ return 0;
+}
+
--- /dev/null
+# GNU Makefile -- Makefile
+# 2009 Reto Zingg
+
+CC = gcc
+DBG = gdb
+STD = _GNU_SOURCE
+CFLAGS = `pkg-config hildon-1 --cflags` -I/usr/include/dbus-1.0/ -I/usr/lib/dbus-1.0/include/
+LFLAGS = -shared `pkg-config hildon-1 --libs`
+
+MAIN_OBJ = mancala-ui-plugin.o
+
+
+
+#'$<' is filename of input, '$@' is filename of output
+.c.o:
+ $(CC) -c -g$(DBG) -Wall $(CFLAGS) -D$(STD) $<
+.h.o:
+ $(CC) -c -g$(DBG) -Wall $(CFLAGS) -D$(STD) $<
+
+all: $(MAIN_OBJ)
+ $(CC) $(LFLAGS) $(MAIN_OBJ) -o mancala-ui-plugin.so
+
+install: all
+ mkdir -p $(DESTDIR)/home/opt/mancala/plugin/
+ cp mancala-ui-plugin.so $(DESTDIR)/home/opt/mancala/plugin/
+
+clean:
+ rm -f *.o *.core *.swp *~ *.log
+
+clobber: clean
+ rm -f mancala-ui-plugin.so
+
+
+
--- /dev/null
+/*
+* This file is part of Mancala
+*
+* Originally from Crazyparking:
+* Copyright (C) 2005 INdT - Instituto Nokia de Tecnologia
+* http://www.indt.org/maemo
+*
+* adapted:
+* Copyright (c) 2009 Reto Zingg
+*
+* Some of the code is based on the examples on:
+* http://wiki.maemo.org/Documentation/Maemo_5_Developer_Guide
+*
+* This software is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public License
+* as published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA
+*
+*/
+
+
+#include <stdio.h>
+#include <hildon/hildon.h>
+#include <gtk/gtk.h>
+#include <startup_plugin.h>
+#include <startup_app.h>
+#include <dbus/dbus-glib.h>
+
+
+static GtkWidget *load_plugin (void);
+static void unload_plugin (void);
+static void write_config (void);
+
+static GameStartupInfo gs;
+
+static StartupPluginInfo plugin_info = {
+ load_plugin,
+ unload_plugin,
+ write_config,
+ NULL
+};
+
+
+
+
+STARTUP_INIT_PLUGIN(plugin_info, gs, FALSE, FALSE)
+
+// the following does not work proper until osso_game_startup is
+// implemented as stackable window...
+
+// static void destroy_help_subwindow (void)
+// {
+// StartupApp *app = gs.ui->app;
+// osso_application_top(app->osso, app->path, NULL);
+// }
+//
+// static void show_help_subwindow (void)
+// {
+// GtkWidget *win;
+// GtkWidget *textbox;
+// GtkTextBuffer *textbox_buffer;
+// gchar *textbox_text;
+// PangoFontDescription *font_desc;
+// GtkWidget *pannable_text;
+//
+// /* Create the subwindow (a stackable window) */
+// win = hildon_stackable_window_new();
+// gtk_window_set_title ( GTK_WINDOW (win), "Help");
+//
+// /* Create and pack labels */
+// textbox_text = g_strdup_printf("Welcome to Mancala, the ancient African game of skill!\n\nMancala is a very simple, easy-to-learn game. Each player begins with a horizontal row of holes or pits filled with a certain number of stones. At either end of the board are the players' home pits, which are used to keep score. In this case, the human player has the left home pit and the upper row holes. A move is made by clicking into the hole you wish to move from. The stones are then picked up and distributed, one to each hole, moving toward your home pit is reached, and then moving through your opponent's row, bypassing his/her home, and moving back towards in a circle (counterclockwise), until all the stones have been distributed.\n\nIf the last stone is placed in your home, you receive an extra turn. If the last stone lands in an empty hole on your side, you 'capture' the stones in the opposite hole on your opponent's side, moving them to your home.\n\nThe game ends when one player cannot play (ie. there are no stones on his/her side of the board. The player who has the most stones on his/her *side* wins.");
+//
+// textbox = hildon_text_view_new();
+// gtk_text_view_set_editable(GTK_TEXT_VIEW(textbox), FALSE);
+// // gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(textbox), FALSE);
+// gtk_text_view_set_indent(GTK_TEXT_VIEW(textbox), 10);
+// gtk_text_view_set_left_margin(GTK_TEXT_VIEW(textbox), 10);
+// gtk_text_view_set_right_margin(GTK_TEXT_VIEW(textbox), 10);
+// gtk_text_view_set_pixels_above_lines(GTK_TEXT_VIEW(textbox), 3);
+// gtk_text_view_set_pixels_below_lines(GTK_TEXT_VIEW(textbox), 2);
+// gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(textbox), GTK_WRAP_WORD);
+// // gtk_widget_set_sensitive(textbox, FALSE);
+// font_desc = pango_font_description_from_string ("vera 18");
+// gtk_widget_modify_font(textbox, font_desc);
+// pango_font_description_free (font_desc);
+//
+// textbox_buffer = hildon_text_view_get_buffer (HILDON_TEXT_VIEW (textbox));
+//
+// gtk_text_buffer_set_text(textbox_buffer, textbox_text, -1);
+//
+//
+// pannable_text = hildon_pannable_area_new();
+// hildon_pannable_area_add_with_viewport (HILDON_PANNABLE_AREA(pannable_text), textbox);
+//
+// gtk_container_add (GTK_CONTAINER (win), pannable_text);
+//
+// g_signal_connect (win, "destroy", destroy_help_subwindow, NULL);
+//
+//
+// /* This call show the window and also add the window to the stack */
+// gtk_widget_show_all (win);
+// }
+
+
+static void show_help_browser (void)
+{
+ char *uri = "file:///home/opt/mancala/data/mancala.html";
+ DBusGConnection *connection;
+ GError *error = NULL;
+ DBusGProxy *proxy;
+
+ connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+
+ if (connection == NULL){
+ printf("Dbus connection failed: %s\n",error->message);
+ g_error_free (error);
+ return;
+ }
+
+ proxy = dbus_g_proxy_new_for_name (connection,
+ "com.nokia.osso_browser",
+ "/com/nokia/osso_browser/request",
+ "com.nokia.osso_browser");
+
+ error = NULL;
+
+ if (!dbus_g_proxy_call (proxy, "load_url", &error, G_TYPE_STRING, uri, G_TYPE_INVALID, G_TYPE_INVALID)){
+ printf("Load_URL failed: %s\n",error->message);
+ g_error_free (error);
+ }
+
+}
+
+
+static GtkWidget *load_plugin (void)
+{
+ GtkWidget *button;
+ button = gtk_button_new_with_label ("Instuctions");
+
+ g_signal_connect (button, "clicked", G_CALLBACK (show_help_browser), NULL);
+
+ return GTK_WIDGET(button);
+
+}
+
+static void
+unload_plugin (void)
+{
+
+}
+
+static void
+write_config (void)
+{
+
+}
+
+