Menu script working.

This commit is contained in:
Scott Duensing 2020-03-29 22:13:50 -05:00
parent b14335a736
commit 98ff928553
344 changed files with 1365 additions and 92 deletions

2
.gitattributes vendored
View file

@ -1,3 +1,5 @@
*.png filter=lfs diff=lfs merge=lfs -text
*.xcf filter=lfs diff=lfs merge=lfs -text
*.mp4 filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.odt filter=lfs diff=lfs merge=lfs -text

BIN
singe/FreeSansBold.ttf (Stored with Git LFS) Normal file

Binary file not shown.

BIN
singe/Manual.odt (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -29,39 +29,6 @@ function compareTitles(a, b)
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)
@ -72,16 +39,221 @@ function box(x1, y1, x2, y2)
end
-- Remove whitespace from string
function trim(s)
return (s:gsub("^%s*(.-)%s*$", "%1"))
end
function wrapText(text, maxWidth)
local words = {}
local line = ""
local lastLine = ""
local lastWord = ""
local newLine = false
-- Break input into words
for w in text:gmatch("%S+") do
words[#words+1] = w
end
-- Iterate over words and try to fit them in the space given
for _, word in ipairs(words) do
-- Add new word to line
lastLine = line
if newLine then
line = lastWord
newLine = false
end
line = trim(line .. " " .. word)
-- Create a temporary sprite to see how wide this is
if string.len(line) > 0 then
spriteTemp = fontToSprite(line)
if spriteGetWidth(spriteTemp) > maxWidth then
-- We wrapped - Create sprite from this line before the last word was added
table.insert(TEXT_SPRITE_LIST, fontToSprite(lastLine))
-- Get ready for the next line
line = ""
lastWord = word
newLine = true
end
spriteUnload(spriteTemp)
end
end
if newLine then
line = lastWord
end
if string.len(line) > 0 then
-- Create sprite from remaining text
table.insert(TEXT_SPRITE_LIST, fontToSprite(line))
end
end
function loadGameAssets(firstGame)
if not firstGame then
spriteUnload(SPRITE_CABINET)
spriteUnload(SPRITE_MARQUEE)
videoUnload(VIDEO_ATTRACT)
for _, handle in ipairs(TEXT_SPRITE_LIST) do
spriteUnload(handle)
end
TEXT_SPRITE_LIST = {}
end
SPRITE_CABINET = spriteLoad(GAME_LIST[GAME_SELECTED].CABINET)
SPRITE_MARQUEE = spriteLoad(GAME_LIST[GAME_SELECTED].MARQUEE)
VIDEO_ATTRACT = videoLoad(GAME_LIST[GAME_SELECTED].ATTRACT)
videoPlay(VIDEO_ATTRACT)
videoSeek(VIDEO_ATTRACT, GAME_LIST[GAME_SELECTED].ATTRACT_START)
videoSetVolume(VIDEO_ATTRACT, 0, 0)
wrapText(GAME_LIST[GAME_SELECTED].DESCRIPTION, TEXT_W)
end
function onInputPressed(what)
if what == SWITCH_LEFT then
GAME_SELECTED = GAME_SELECTED - 1
if GAME_SELECTED < 1 then
GAME_SELECTED = GAME_COUNT
end
loadGameAssets(false)
end
if what == SWITCH_RIGHT then
GAME_SELECTED = GAME_SELECTED + 1
if GAME_SELECTED > GAME_COUNT then
GAME_SELECTED = 1
end
loadGameAssets(false)
end
if what == SWITCH_START1 or what == SWITCH_START2 or what == SWITCH_BUTTON1 or what == SWITCH_BUTTON2 or what == SWITCH_BUTTON3 or what == SWITCH_BUTTON4 then
scriptPush(GAME_LIST[GAME_SELECTED])
end
end
function onOverlayUpdate()
local x = 0
local y = 0
overlayClear()
overlayPrint(1, 1, "Overlay is " .. overlayGetWidth() .. "x" .. overlayGetHeight())
-- Cabinet image
x = CABINET_X + (CABINET_W - spriteGetWidth(SPRITE_CABINET)) * 0.5
y = CABINET_Y + (CABINET_H - spriteGetHeight(SPRITE_CABINET)) * 0.5
spriteDraw(x, y, SPRITE_CABINET)
box(50, 50, 250, 430)
videoDraw(vid, 300, 100, 620, 300)
fontPrint(300, 310, "Font Test")
-- Marquee Image
x = MARQUEE_X + (MARQUEE_W - spriteGetWidth(SPRITE_MARQUEE)) * 0.5
y = MARQUEE_Y + (MARQUEE_H - spriteGetHeight(SPRITE_MARQUEE)) * 0.5
spriteDraw(x, y, SPRITE_MARQUEE)
-- Attract Mode Video
videoDraw(VIDEO_ATTRACT, VIDEO_X, VIDEO_Y, VIDEO_X + VIDEO_W, VIDEO_Y + VIDEO_H)
if videoGetFrame(VIDEO_ATTRACT) > GAME_LIST[GAME_SELECTED].ATTRACT_END then
videoSeek(VIDEO_ATTRACT, GAME_LIST[GAME_SELECTED].ATTRACT_START)
end
-- Game Description
colorForeground(255, 255, 255, 255)
y = TEXT_Y
for _, handle in ipairs(TEXT_SPRITE_LIST) do
spriteDraw(TEXT_X, y, handle)
y = y + spriteGetHeight(handle) + 1
end
return(OVERLAY_UPDATED)
end
-- Search for games.dat files in subdirectories
GAME_LIST = {}
GAME_COUNT = 0
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(GAME_LIST, value)
GAME_COUNT = GAME_COUNT + 1
end
GAMES = {}
end
end
end
end
end
table.sort(GAME_LIST, compareTitles)
if GAME_COUNT == 0 then
debugPrint("No games found! Exiting.")
singeQuit()
end
discPlay()
overlaySetResolution(vldpGetWidth(), vldpGetHeight())
freeSans18 = fontLoad("Singe/FreeSansBold.ttf", 18)
fontQuality(FONT_QUALITY_BLENDED)
fontSelect(freeSans18)
MARGIN_X = 25
MARGIN_Y = 25
VIDEO_W = 320
VIDEO_H = 200
MARQUEE_H = 75
MARQUEE_W = VIDEO_W
MARQUEE_X = overlayGetWidth() - MARGIN_X - MARQUEE_W
MARQUEE_Y = MARGIN_Y
VIDEO_X = overlayGetWidth() - MARGIN_X - VIDEO_W
VIDEO_Y = MARGIN_Y + MARQUEE_H + MARGIN_Y
TEXT_W = VIDEO_W
TEXT_X = overlayGetWidth() - MARGIN_X - TEXT_W
TEXT_Y = VIDEO_Y + VIDEO_H + MARGIN_Y
TEXT_H = overlayGetHeight() - MARGIN_Y - TEXT_Y
CABINET_X = MARGIN_X
CABINET_Y = MARGIN_Y
CABINET_W = VIDEO_X - MARGIN_X - CABINET_X
CABINET_H = overlayGetHeight() - MARGIN_Y - CABINET_Y
--[[
Cabinet is 325x430
Marquee is 320x75
Video is 320x200
Text is 320x105
--]]
--[[
debugPrint("Cabinet is " .. CABINET_W .. "x" .. CABINET_H)
debugPrint("Marquee is " .. MARQUEE_W .. "x" .. MARQUEE_H)
debugPrint(" Video is " .. VIDEO_W .. "x" .. VIDEO_H)
debugPrint(" Text is " .. TEXT_W .. "x" .. TEXT_H)
--]]
TEXT_SPRITE_LIST = {}
-- Prime the pump
GAME_SELECTED = 1
loadGameAssets(true)

View file

@ -65,7 +65,7 @@ function doBuild() {
echo "Compressing ${TARGET}..."
${CROSS}-strip "${TARGET}"
upx -9 "${TARGET}"
upx -q -9 "${TARGET}"
popd
}

View file

@ -22,16 +22,7 @@
#define EMBED_HERE
#include "font.h"
#include "icon.h"
#include "kangarooPunchLogo.h"
#include "singeLogo.h"
#include "laserDisc.h"
#include "magnifyingGlass.h"
#include "indexing.h"
#include "Framework_singe.h"
#include "controls_cfg.h"
#include "Menu_singe.h"
#include "menuBackground_mkv.h"
#undef EMBEDDED_H
#include "embedded.h"
#undef EMBED_HERE

View file

@ -35,6 +35,7 @@
#include "controls_cfg.h"
#include "Menu_singe.h"
#include "menuBackground_mkv.h"
#include "Manual_pdf.h"
#endif // EMBEDDED_H

View file

@ -3,43 +3,49 @@ GAMES = {
TITLE = ".38 Ambush Alley",
SCRIPT = "ActionMax/38AmbushAlley.singe",
VIDEO = "ActionMax/frame_38AmbushAlley.txt",
DATA = "ActionMax",
STRETCH = false,
NO_MOUSE = false,
RESOLUTION_X = 720,
RESOLUTION_Y = 480,
SINDEN_GUN = "",
CABINET = "ActionMax/cabinet_38AmbushAlley.png",
MARQUEE = "ActionMax/marquee_38AmbushAlley.png",
ATTRACT = "ActionMax/38AmbushAlley.mkv",
ATTRACT_START = 0,
ATTRACT_END = 500,
MARQUEE = "ActionMax/marquee_ActionMax.png",
ATTRACT = "ActionMax/video_38AmbushAlley.mkv",
ATTRACT_START = 3000,
ATTRACT_END = 3500,
YEAR = 1987,
PLATFORM = "ActionMax",
DEVELOPER = "Sourcing International, Ltd.",
PUBLISHER = "Worlds of Wonder, Inc.",
GENERE = "Shooter",
DESCRIPTION = "Get your target practice in with real police officers then hit the streets."
DESCRIPTION = "Get your target practice in with real police officers then hit the streets.",
CREATOR = "Scott Duensing",
SOURCE = "http://kangaroopunch.com"
},
{
TITLE = "Blue Thunder",
SCRIPT = "ActionMax/BlueThunder.singe",
VIDEO = "ActionMax/frame_BlueThunder.txt",
DATA = "ActionMax",
STRETCH = false,
NO_MOUSE = false,
RESOLUTION_X = 720,
RESOLUTION_Y = 480,
SINDEN_GUN = "",
CABINET = "ActionMax/cabinet_BlueThunder.png",
MARQUEE = "ActionMax/marquee_BlueThunder.png",
ATTRACT = "ActionMax/BlueThunder.mkv",
ATTRACT_START = 0,
ATTRACT_END = 500,
MARQUEE = "ActionMax/marquee_ActionMax.png",
ATTRACT = "ActionMax/video_BlueThunder.mkv",
ATTRACT_START = 3000,
ATTRACT_END = 3500,
YEAR = 1987,
PLATFORM = "ActionMax",
DEVELOPER = "Sourcing International, Ltd.",
PUBLISHER = "Worlds of Wonder, Inc.",
GENERE = "Shooter",
DESCRIPTION = "Get in your chopper and take out the bad guys in this action-packed game."
DESCRIPTION = "Get in your chopper and take out the bad guys in this action-packed game.",
CREATOR = "Scott Duensing",
SOURCE = "http://kangaroopunch.com"
},
{
TITLE = "Hydrosub: 2021",
@ -52,57 +58,65 @@ GAMES = {
RESOLUTION_Y = 480,
SINDEN_GUN = "",
CABINET = "ActionMax/cabinet_Hydrosub2021.png",
MARQUEE = "ActionMax/marquee_Hydrosub2021.png",
ATTRACT = "ActionMax/Hydrosub2021.mkv",
ATTRACT_START = 0,
ATTRACT_END = 500,
MARQUEE = "ActionMax/marquee_ActionMax.png",
ATTRACT = "ActionMax/video_Hydrosub2021.mkv",
ATTRACT_START = 3000,
ATTRACT_END = 3500,
YEAR = 1987,
PLATFORM = "ActionMax",
DEVELOPER = "Sourcing International, Ltd.",
PUBLISHER = "Worlds of Wonder, Inc.",
GENERE = "Shooter",
DESCRIPTION = "Shootout beneath the ocean!"
DESCRIPTION = "Shootout beneath the ocean!",
CREATOR = "Scott Duensing",
SOURCE = "http://kangaroopunch.com"
},
{
TITLE = "Rescue of Pops Ghostly, The",
SCRIPT = "ActionMax/PopsGhostly.singe",
VIDEO = "ActionMax/frame_PopsGhostly.txt",
DATA = "ActionMax",
STRETCH = false,
NO_MOUSE = false,
RESOLUTION_X = 720,
RESOLUTION_Y = 480,
SINDEN_GUN = "",
CABINET = "ActionMax/cabinet_PopsGhostly.png",
MARQUEE = "ActionMax/marquee_PopsGhostly.png",
ATTRACT = "ActionMax/PopsGhostly.mkv",
ATTRACT_START = 0,
ATTRACT_END = 500,
MARQUEE = "ActionMax/marquee_ActionMax.png",
ATTRACT = "ActionMax/video_PopsGhostly.mkv",
ATTRACT_START = 3000,
ATTRACT_END = 3500,
YEAR = 1987,
PLATFORM = "ActionMax",
DEVELOPER = "Sourcing International, Ltd.",
PUBLISHER = "Worlds of Wonder, Inc.",
GENERE = "Shooter",
DESCRIPTION = "Help Pops Ghostly and his family get rid of the bad spirits who have taken over the house."
DESCRIPTION = "Help Pops Ghostly and his family get rid of the bad spirits who have taken over the house.",
CREATOR = "Scott Duensing",
SOURCE = "http://kangaroopunch.com"
},
{
TITLE = "Sonic Fury",
SCRIPT = "ActionMax/SonicFury.singe",
VIDEO = "ActionMax/frame_SonicFury.txt",
DATA = "ActionMax",
STRETCH = false,
NO_MOUSE = false,
RESOLUTION_X = 720,
RESOLUTION_Y = 480,
SINDEN_GUN = "",
CABINET = "ActionMax/cabinet_SonicFury.png",
MARQUEE = "ActionMax/marquee_SonicFury.png",
ATTRACT = "ActionMax/SonicFury.mkv",
ATTRACT_START = 0,
ATTRACT_END = 500,
MARQUEE = "ActionMax/marquee_ActionMax.png",
ATTRACT = "ActionMax/video_SonicFury.mkv",
ATTRACT_START = 3000,
ATTRACT_END = 3500,
YEAR = 1987,
PLATFORM = "ActionMax",
DEVELOPER = "Sourcing International, Ltd.",
PUBLISHER = "Worlds of Wonder, Inc.",
GENERE = "Shooter",
DESCRIPTION = "Shoot it out with the bad guys in your fighter jet!"
DESCRIPTION = "Shoot it out with the bad guys in your fighter jet!",
CREATOR = "Scott Duensing",
SOURCE = "http://kangaroopunch.com"
}
}

View file

@ -689,11 +689,19 @@ void showUsage(char *name, char *message) {
// Extract any missing support files. We do this here so they're not generated if launched from a front end.
if (!utilPathExists("Singe")) utilMkDirP("Singe", 0777);
// Singe/Framework.singe
temp = utilCreateString("Singe%cFramework.singe", utilGetPathSeparator());
created |= extractFile(temp, Framework_singe, Framework_singe_len);
free(temp);
/*
// Singe/controls.cfg.example
temp = utilCreateString("Singe%ccontrols.cfg.example", utilGetPathSeparator());
created |= extractFile(temp, controls_cfg, controls_cfg_len);
free(temp);
// Singe/Manual.pdf
temp = utilCreateString("Singe%Manual.pdf", utilGetPathSeparator());
created |= extractFile(temp, Manual_pdf, Manual_pdf_len);
free(temp);
// Singe/Menu.singe
temp = utilCreateString("Singe%cMenu.singe", utilGetPathSeparator());
created |= extractFile(temp, Menu_singe, Menu_singe_len);
@ -702,11 +710,7 @@ void showUsage(char *name, char *message) {
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);
free(temp);
temp = NULL;
if (created) utilSay("");

View file

@ -590,13 +590,19 @@ createEmbeddedBinary controls.cfg controls_cfg.h CONTROLS_CFG_H
createEmbeddedBinary Menu.singe Menu_singe.h MENU_SINGE_H
# === Singe Menu Background Video ===
if [[ ! -f menuBackground.mkv ]]; then
if [[ ! -f menuBackground_mkv.h ]]; 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
rm menuBackground.mkv
fi
popd
# === Singe Manual ===
libreoffice --headless "-env:UserInstallation=file:///tmp/LibreOffice_Conversion_${USER}" --convert-to pdf:writer_pdf_Export Manual.odt
createEmbeddedBinary Manual.pdf Manual_pdf.h MANUAL_H
rm Manual.pdf
# Clean Uo
case "${G_PLATFORM}" in
mac)

View file

@ -3508,14 +3508,17 @@ void singe(SDL_Window *window, SDL_Renderer *renderer, ConfigT *conf) {
lua_register(_global.luaContext, "scriptExecute", apiScriptExecute);
lua_register(_global.luaContext, "scriptPush", apiScriptPush);
lua_register(_global.luaContext, "singeGetPauseFlag", apiSingeGetPauseFlag);
lua_register(_global.luaContext, "singeSetPauseFlag", apiSingeSetPauseFlag);
lua_register(_global.luaContext, "singeEnablePauseKey", apiSingeEnablePauseKey);
lua_register(_global.luaContext, "singeDisablePauseKey", apiSingeDisablePauseKey);
lua_register(_global.luaContext, "singeEnablePauseKey", apiSingeEnablePauseKey);
lua_register(_global.luaContext, "singeGetHeight", apiDaphneGetHeight);
lua_register(_global.luaContext, "singeGetPauseFlag", apiSingeGetPauseFlag);
lua_register(_global.luaContext, "singeGetScriptPath", apiSingeGetScriptPath);
lua_register(_global.luaContext, "singeGetWidth", apiDaphneGetWidth);
lua_register(_global.luaContext, "singeScreenshot", apiDaphneScreenshot);
lua_register(_global.luaContext, "singeSetGameName", apiSingeSetGameName);
lua_register(_global.luaContext, "singeSetPauseFlag", apiSingeSetPauseFlag);
lua_register(_global.luaContext, "singeQuit", apiSingeQuit);
lua_register(_global.luaContext, "singeVersion", apiSingeVersion);
lua_register(_global.luaContext, "singeSetGameName", apiSingeSetGameName);
lua_register(_global.luaContext, "singeGetScriptPath", apiSingeGetScriptPath);
lua_register(_global.luaContext, "soundFullStop", apiSoundFullStop);
lua_register(_global.luaContext, "soundGetVolume", apiSoundGetVolume);

View file

@ -31,7 +31,7 @@
// Don't forget to update singe.rc!
#define SINGE_VERSION 2.00
#define VERSION_STRING "v2.00b13"
#define VERSION_STRING "v2.00b14"
#define COPYRIGHT_END_YEAR "2020"

View file

@ -156,7 +156,8 @@ HEADERS += \
indexing.h \
controls_cfg.h \
Menu_singe.h \
menuBackground_mkv.h
menuBackground_mkv.h \
Manual_pdf.h
SOURCES += \
$$ARGPARSER_SOURCES \

View file

@ -1,7 +1,7 @@
101 ICON "/tmp/icon.ico"
1 VERSIONINFO
FILEVERSION 2,0,0,13
PRODUCTVERSION 2,0,0,13
FILEVERSION 2,0,0,14
PRODUCTVERSION 2,0,0,14
BEGIN
BLOCK "StringFileInfo"
BEGIN
@ -9,12 +9,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Kangaroo Punch Studios"
VALUE "FileDescription", "Somewhat Interactive Nostalgic Game Engine"
VALUE "FileVersion", "2.00b13"
VALUE "FileVersion", "2.00b14"
VALUE "InternalName", "Singe"
VALUE "LegalCopyright", "Copyright 2006-2020 Scott C. Duensing"
VALUE "OriginalFilename", "singe.exe"
VALUE "ProductName", "Singe"
VALUE "ProductVersion", "2.00b13"
VALUE "ProductVersion", "2.00b14"
END
END
BLOCK "VarFileInfo"

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show more