//gs includes
#include <acknex.h>
#include <windows.h>
#include <default.c>
//including paths
#define PRAGMA_PATH "filme"
#define PRAGMA_PATH "pause"
//fonts
AddFontResource("exo_light.otf");
AddFontResource("exo_regular.otf");
FONT* exo_light = "exo_light#15";
FONT* exo_regular = "exo_regular#16";
FONT* exo_regular_big = "exo_regular#20";
//vars
var count_filme = 0;
var count_pause = 0;
var current_index = -1;
var mhandle = NULL;
var pause = 0;
var show_fn = 0;
VECTOR desktop_size;
//strings
STRING* count_filme_str = "";
STRING* nj_str = "Developed by NeoJones";
//bmaps
BMAP* nj_logo = "nj_logo.tga";
//text objects
TEXT* txt_label_filme =
{
string("Gefundene Filme (");
pos_x = 30;
pos_y = 30;
font = exo_regular;
size_x = 200;
layer = 10;
}
TEXT* txt_filme =
{
strings = 100;
pos_x = 30;
pos_y = 60;
font = exo_regular;
layer = 10;
}
TEXT* txt_bilder_label =
{
string("Pausen-Standbild:");
pos_x = 500;
pos_y = 30;
font = exo_regular;
layer = 10;
}
TEXT* txt_bilder =
{
strings = 100;
pos_x = 500;
pos_y = 60;
font = exo_regular;
layer = 10;
}
TEXT* txt_message =
{
string("Bitte die Enter-Taste drücken, um den Play-Modus zu aktivieren");
font = exo_regular_big;
flags = CENTER_X;
}
//panels
PANEL* pause_pan =
{
layer = 9;
}
PANEL* nj_logo_pan =
{
digits(25,60, 5 ,exo_regular_big,1,nj_str);
bmap = nj_logo;
layer = 9;
flags = CENTER_X;
}
function show_filenames()
{
while(1)
{
//show or hide filenames on key_d
if(key_d)
{
while (key_d == 1) { wait(1); }
if(show_fn == 0)
{
show_fn = 1;
set(txt_label_filme, SHOW);
set(txt_filme, SHOW);
set(txt_bilder_label, SHOW);
set(txt_bilder, SHOW);
}
else
{
show_fn = 0;
reset(txt_label_filme, SHOW);
reset(txt_filme, SHOW);
reset(txt_bilder_label, SHOW);
reset(txt_bilder, SHOW);
}
}
wait(1);
}
}
function start()
{
//search files in folder "filme"
count_filme = txt_for_dir(txt_filme,"filme\\*.wmv");
//save the number of files as text
str_for_num(count_filme_str,count_filme);
str_cat((txt_label_filme.pstring)[0], count_filme_str);
str_cat((txt_label_filme.pstring)[0], "):");
//search images in folder "pause"
count_pause = txt_for_dir(txt_bilder,"pause\\*.jpg");
// stop here, if no files in folder
if(count_pause > 0 && count_filme > 0)
{
STRING* tmp_str = "";
var i;
//write each correct filename with foldername in string
for(i = 0; i < count_filme; i++)
{
tmp_str = str_create("filme/");
str_cat(tmp_str, (txt_filme.pstring)[i]);
str_cpy((txt_filme.pstring)[i], tmp_str);
}
tmp_str = str_create("pause/");
str_cat(tmp_str, (txt_bilder.pstring)[0]);
str_cpy((txt_bilder.pstring)[0], tmp_str);
str_cpy(tmp_str, (txt_bilder.pstring)[0]);
BMAP* pause_bmap = bmap_create(tmp_str);
while(pause_bmap == NULL){wait(1);}
pause_pan.bmap = pause_bmap;
//set correct panel sizes and positions
pause_pan.scale_x = screen_size.x/bmap_width(pause_pan.bmap);
pause_pan.scale_y = screen_size.y/bmap_height(pause_pan.bmap);
txt_message.size_x = screen_size.x;
txt_message.size_y = screen_size.y;
txt_message.pos_x = screen_size.x/2;
txt_message.pos_y = screen_size.y/2;
nj_logo_pan.pos_x = (screen_size.x/2)-25;
nj_logo_pan.pos_y = screen_size.y-120;
//show logo, message and wait for the enter key
set(nj_logo_pan, SHOW);
set(txt_message, SHOW);
while (key_enter == 0) { wait(1); }
//show or hide correct panels and textobjects
reset(txt_label_filme, SHOW);
reset(txt_filme, SHOW);
reset(txt_bilder_label, SHOW);
reset(txt_bilder, SHOW);
reset(txt_message, SHOW);
reset(nj_logo_pan, SHOW);
set(pause_pan, SHOW);
//wait, if enter is pressed
while (key_enter == 1) { wait(1); }
while(1)
{
//play next movie on key enter
if(key_enter)
{
while (key_enter == 1) { wait(1); }
current_index++;
if(current_index == count_filme)
{
current_index = 0;
}
reset(pause_pan, SHOW);
media_stop(mhandle);
mhandle = media_play((txt_filme.pstring)[current_index],NULL,100);
}
//play or pause the movie on key space and show or hide the pause image
if(key_space)
{
while (key_space == 1) { wait(1); }
if(media_playing(mhandle) != 0)
{
if(pause == 0)
{
pause = 1;
set(pause_pan, SHOW);
media_pause(mhandle);
}
else
{
pause = 0;
reset(pause_pan, SHOW);
media_start(mhandle);
}
}
}
//restart current movie
if(key_bksp)
{
while (key_bksp == 1) { wait(1); }
media_stop(mhandle);
mhandle = media_play((txt_filme.pstring)[current_index],NULL,100);
}
//show pause image after playing a movie
if(pause == 0 && media_playing(mhandle) == 0)
{
set(pause_pan, SHOW);
}
wait(1);
}
}
}
//////////////////////////////////////////////////////////////////////////////////////////
function main()
{
//standart optionen setzen
fps_max = 60;
text_outline = 30;
sky_color.red = 1;
sky_color.green = 1;
sky_color.blue = 1;
//desktopauflösung ermitteln
desktop_size.x = sys_metrics(0);
desktop_size.y = sys_metrics(1);
//auf ermittelte oder gespeicherte auflösung umschalten
video_set(desktop_size.x,desktop_size.y,0,1);
wait(2);
//start functions
start();
show_filenames();
}