From a1a54548d5ff470df6345452cfa0bb92f5948317 Mon Sep 17 00:00:00 2001 From: Scott Duensing Date: Sun, 22 Mar 2020 16:36:07 -0500 Subject: [PATCH] Start of menu embeds. --- .gitattributes | 1 + .gitignore | 3 ++ singe/180503_01_PurpleGrid.mp4 | 3 ++ singe/Framework.singe | 16 +++++++ singe/Menu.singe | 87 ++++++++++++++++++++++++++++++++++ singe/embedded.c | 2 + singe/embedded.h | 2 + singe/games.dat | 2 +- singe/main.c | 8 ++++ singe/preBuild.sh | 18 ++++++- singe/singe.c | 50 +++++++++---------- singe/singe.pro | 15 +++--- 12 files changed, 172 insertions(+), 35 deletions(-) create mode 100644 singe/180503_01_PurpleGrid.mp4 create mode 100644 singe/Menu.singe diff --git a/.gitattributes b/.gitattributes index 86acde727..ac3013936 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,3 @@ *.png filter=lfs diff=lfs merge=lfs -text *.xcf filter=lfs diff=lfs merge=lfs -text +*.mp4 filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore index 029d2cc85..7e8d07263 100644 --- a/.gitignore +++ b/.gitignore @@ -46,3 +46,6 @@ singe/Framework_singe.h singe/controls_cfg.h videotest/indexing/ Makefile.in +singe/menuBackground.mkv +singe/menuBackground_mkv.h +singe/Menu_singe.h diff --git a/singe/180503_01_PurpleGrid.mp4 b/singe/180503_01_PurpleGrid.mp4 new file mode 100644 index 000000000..7f85af425 --- /dev/null +++ b/singe/180503_01_PurpleGrid.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d0a1b8d7949ee9563177636262612a53d8f4c3700df0c87abb84dbcc15e2fc89 +size 26521887 diff --git a/singe/Framework.singe b/singe/Framework.singe index ed9bceef7..7e65e01e3 100644 --- a/singe/Framework.singe +++ b/singe/Framework.singe @@ -40,6 +40,22 @@ function utilDeepCopy(orig) end +function utilDump(o) + if type(o) == 'table' then + local s = '{ ' + for k,v in pairs(o) do + if type(k) ~= 'number' then + k = '"'..k..'"' + end + s = s .. '['..k..'] = ' .. utilDump(v) .. ',' + end + return s .. '} ' + else + return tostring(o) + end +end + + SCANCODE = { A = { name = "A", value = 4 }, B = { name = "B", value = 5 }, diff --git a/singe/Menu.singe b/singe/Menu.singe new file mode 100644 index 000000000..72d6b6072 --- /dev/null +++ b/singe/Menu.singe @@ -0,0 +1,87 @@ +--[[ + * + * Singe 2 + * Copyright (C) 2006-2020 Scott Duensing + * + * 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 + * of the License, 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * +--]] + + +dofile("Singe/Framework.singe") + + +function compareTitles(a, b) + return a.TITLE < b.TITLE +end + + +-- Search for games.dat files in subdirectories +FOUND_GAMES = {} +for dir in lfs.dir(".") do + if dir ~= "." and dir ~= ".." then + local dirattr = lfs.attributes(dir) + if dirattr.mode == "directory" then + for file in lfs.dir(dir .. "/.") do + if file == "games.dat" then + -- Load games.dat + dofile(dir .. "/games.dat") + for key,value in pairs(GAMES) do + table.insert(FOUND_GAMES, value) + end + GAMES = {} + end + end + end + end +end +table.sort(FOUND_GAMES, compareTitles) + + +font = fontLoad("ActionMax/font_LED_Real.ttf", 32); + +vid = videoLoad("ActionMax/video_BlueThunder.mkv"); +videoPlay(vid) + +discPlay() +overlaySetResolution(vldpGetWidth(), vldpGetHeight()) +colorForeground(255, 0, 0, 255) + + + +function box(x1, y1, x2, y2) + + overlayLine(x1, y1, x2, y1) + overlayLine(x2, y1, x2, y2) + overlayLine(x2, y2, x1, y2) + overlayLine(x1, y2, x1, y1) + +end + + +function onOverlayUpdate() + + overlayClear() + + overlayPrint(1, 1, "Overlay is " .. overlayGetWidth() .. "x" .. overlayGetHeight()) + + box(50, 50, 250, 430) + videoDraw(vid, 300, 100, 620, 300) + fontPrint(300, 310, "Font Test") + + return(OVERLAY_UPDATED) + +end diff --git a/singe/embedded.c b/singe/embedded.c index 56324e602..560f596c6 100644 --- a/singe/embedded.c +++ b/singe/embedded.c @@ -31,5 +31,7 @@ #include "indexing.h" #include "Framework_singe.h" #include "controls_cfg.h" +#include "Menu_singe.h" +#include "menuBackground_mkv.h" #undef EMBED_HERE diff --git a/singe/embedded.h b/singe/embedded.h index 6f81791fd..8bae01818 100644 --- a/singe/embedded.h +++ b/singe/embedded.h @@ -33,6 +33,8 @@ #include "indexing.h" #include "Framework_singe.h" #include "controls_cfg.h" +#include "Menu_singe.h" +#include "menuBackground_mkv.h" #endif // EMBEDDED_H diff --git a/singe/games.dat b/singe/games.dat index e978ebdba..d0375f212 100644 --- a/singe/games.dat +++ b/singe/games.dat @@ -72,7 +72,7 @@ GAMES = { DESCRIPTION = "Shootout beneath the ocean!" }, { - TITLE = "The Rescue of Pops Ghostly", + TITLE = "Rescue of Pops Ghostly, The", SCRIPT = "ActionMax/PopsGhostly.singe", VIDEO = "ActionMax/frame_PopsGhostly.txt", DATA = "ActionMax", diff --git a/singe/main.c b/singe/main.c index 6fcb96d3f..bab880908 100644 --- a/singe/main.c +++ b/singe/main.c @@ -125,6 +125,14 @@ void showUsage(char *name, char *message) { temp = utilCreateString("Singe%cFramework.singe", utilGetPathSeparator()); created |= extractFile(temp, Framework_singe, Framework_singe_len); free(temp); + // Singe/Menu.singe + temp = utilCreateString("Singe%cMenu.singe", utilGetPathSeparator()); + created |= extractFile(temp, Menu_singe, Menu_singe_len); + free(temp); + // Singe/menuBackground.mkv + temp = utilCreateString("Singe%cmenuBackground.mkv", utilGetPathSeparator()); + created |= extractFile(temp, menuBackground_mkv, menuBackground_mkv_len); + free(temp); // Singe/controls.cfg.example temp = utilCreateString("Singe%ccontrols.cfg.example", utilGetPathSeparator()); created |= extractFile(temp, controls_cfg, controls_cfg_len); diff --git a/singe/preBuild.sh b/singe/preBuild.sh index e3364fee6..e6e0d6d90 100755 --- a/singe/preBuild.sh +++ b/singe/preBuild.sh @@ -29,12 +29,14 @@ if [[ -z $1 ]]; then G_THIRDPARTY=$(pwd)/thirdparty G_DEST="$(pwd)/../thirdparty-build/${G_PLATFORM}/${G_BITS}" G_TYPE=static + G_PROJECT=$(pwd) else G_THIRDPARTY=$1 G_BITS=$3 G_PLATFORM=$4 G_DEST=$2/$4/$3 - G_TYPE=static + G_TYPE=$5 + G_PROJECT=$6 fi G_INSTALLED="${G_DEST}/installed" @@ -553,7 +555,9 @@ if [[ ! -e "${G_INSTALLED}/lib/everything.a" ]]; then popd fi -rm font.h icon.h kangarooPunchLogo.h singeLogo.h laserDisc.h magnifyingGlass.h indexing.h Framework_singe.h controls_cfg.h +pushd "${G_PROJECT}" + +rm font.h icon.h kangarooPunchLogo.h singeLogo.h laserDisc.h magnifyingGlass.h indexing.h Framework_singe.h controls_cfg.h Menu_singe.h || true # === Overlay Font === createEmbeddedImage font @@ -582,6 +586,16 @@ createEmbeddedBinary Framework.singe Framework_singe.h FRAMEWORK_SINGE_H # === Default Config === createEmbeddedBinary controls.cfg controls_cfg.h CONTROLS_CFG_H +# === Singe Menu App === +createEmbeddedBinary Menu.singe Menu_singe.h MENU_SINGE_H + +# === Singe Menu Background Video === +if [[ ! -f menuBackground.mkv ]]; then + ffmpeg -i 180503_01_PurpleGrid.mp4 -filter:v 'crop=ih/3*4:ih' -vf scale=720:480 -c:v libx264 -c:a copy menuBackground.mkv + createEmbeddedBinary menuBackground.mkv menuBackground_mkv.h MENUBACKGROUND_MKV_H +fi + +popd # Clean Uo case "${G_PLATFORM}" in diff --git a/singe/singe.c b/singe/singe.c index 7adb5bb32..b864b0857 100644 --- a/singe/singe.c +++ b/singe/singe.c @@ -3137,33 +3137,33 @@ void putPixel(int32_t x, int32_t y) { void singe(SDL_Window *window, SDL_Renderer *renderer) { - int32_t x = 0; - int32_t y = 0; - int32_t xr = 0; - int32_t yr = 0; - int32_t intReturn = 0; - int64_t thisFrame = -1; - int64_t lastFrame = -1; - uint32_t frameClock = 0; - char *temp = NULL; - char *temp2 = NULL; + int32_t x = 0; + int32_t y = 0; + int32_t xr = 0; + int32_t yr = 0; + int32_t intReturn = 0; + int64_t thisFrame = -1; + int64_t lastFrame = -1; + uint32_t frameClock = 0; + char *temp = NULL; + char *temp2 = NULL; SDL_Rect windowTarget; SDL_Rect sindenWhite; SDL_Rect sindenBlack; - SDL_Color sindenWhiteColor; - SDL_Color sindenBlackColor; - SDL_Texture *overlayTexture = NULL; - SpriteT *sprite = NULL; - SpriteT *spriteTemp = NULL; - SoundT *sound = NULL; - SoundT *soundTemp = NULL; - FontT *font = NULL; - FontT *fontTemp = NULL; - VideoT *video = NULL; - VideoT *videoTemp = NULL; + SDL_Color sindenWhiteColor = { 255, 255, 255, 255 }; + SDL_Color sindenBlackColor = { 0, 0, 0, 255 };; + SDL_Texture *overlayTexture = NULL; + SpriteT *sprite = NULL; + SpriteT *spriteTemp = NULL; + SoundT *sound = NULL; + SoundT *soundTemp = NULL; + FontT *font = NULL; + FontT *fontTemp = NULL; + VideoT *video = NULL; + VideoT *videoTemp = NULL; SDL_Event event; ManyMouseEvent mouseEvent; - MouseT *mouse = NULL; + MouseT *mouse = NULL; // Set up globals memset(&_global, 0, sizeof(GlobalT)); @@ -3531,9 +3531,9 @@ void singe(SDL_Window *window, SDL_Renderer *renderer) { } // Grab mouse -// _global.mouseGrabbed = true; -// SDL_SetWindowGrab(_global.window, SDL_TRUE); -// SDL_ShowCursor(SDL_DISABLE); + _global.mouseGrabbed = true; + SDL_SetWindowGrab(_global.window, SDL_TRUE); + SDL_ShowCursor(SDL_DISABLE); // Clear axis cache for (x=0; x