New blocks for setting and clearing full-screen img.

This commit is contained in:
Martin Haye 2016-10-24 07:08:37 -07:00
parent f3aaa7c6ad
commit 33d9f17503
5 changed files with 73 additions and 18 deletions

View File

@ -134,6 +134,8 @@
<category name="Graphics">
<block type="graphics_set_portrait"></block>
<block type="graphics_clr_portrait"></block>
<block type="graphics_set_fullscreen"></block>
<block type="graphics_clr_fullscreen"></block>
<block type="graphics_set_avatar"></block>
</category>
<category name="Sound">

View File

@ -819,6 +819,31 @@ if (typeof Mythos === "undefined") {
this.setTooltip('Stop displaying a portrait, return to map display');
}
};
Blockly.Blocks['graphics_set_fullscreen'] = {
init: function () {
this.setHelpUrl(Mythos.helpUrl);
this.setColour(54);
this.setPreviousStatement(true);
this.setNextStatement(true);
this.appendDummyInput()
.appendField("Display full screen image ")
.appendField(new Blockly.FieldTextInput(""), "NAME");
this.setOutput(false);
this.setTooltip('Display the given full screen image (by name)');
}
};
Blockly.Blocks['graphics_clr_fullscreen'] = {
init: function () {
this.setHelpUrl(Mythos.helpUrl);
this.setColour(54);
this.setPreviousStatement(true);
this.setNextStatement(true);
this.appendDummyInput()
.appendField("Clear full screen image");
this.setOutput(false);
this.setTooltip('Stop displaying a full screen image, return to map display');
}
};
}
};
}

View File

@ -765,21 +765,25 @@ class A2PackPartitions
def packFrameImage(imgEl)
{
def (name, animFrameNum, animFlags) = decodeImageName(imgEl.@name ?: "img$num")
if (!frames.containsKey(name)) {
def num = frames.size() + 1
frames[name] = [num:num, anim:new AnimBuf()]
withContext("full screen image '$name'") {
if (!frames.containsKey(name)) {
def num = frames.size() + 1
frames[name] = [num:num, anim:new AnimBuf()]
}
frames[name].anim.addImage(animFrameNum, animFlags, parseFrameData(imgEl))
}
frames[name].anim.addImage(animFrameNum, animFlags, parseFrameData(imgEl))
}
def packPortrait(imgEl)
{
def (name, animFrameNum, animFlags) = decodeImageName(imgEl.@name ?: "img$num")
if (!portraits.containsKey(name)) {
def num = portraits.size() + 1
portraits[name] = [num:num, anim:new AnimBuf()]
withContext("portrait '$name'") {
if (!portraits.containsKey(name)) {
def num = portraits.size() + 1
portraits[name] = [num:num, anim:new AnimBuf()]
}
portraits[name].anim.addImage(animFrameNum, animFlags, parse126Data(imgEl))
}
portraits[name].anim.addImage(animFrameNum, animFlags, parse126Data(imgEl))
}
def packTile(imgEl)
@ -2948,7 +2952,10 @@ end
case 'graphics_set_portrait':
packSetPortrait(blk); break
case 'graphics_clr_portrait':
case 'graphics_clr_fullscreen':
packClrPortrait(blk); break
case 'graphics_set_fullscreen':
packSetFullscreen(blk); break
case 'graphics_set_avatar':
packSetAvatar(blk); break
case 'variables_set':
@ -3275,6 +3282,16 @@ end
outIndented("setPortrait(PO${humanNameToSymbol(portraitName, false)})\n")
}
def packSetFullscreen(blk)
{
def imgName = getSingle(blk.field, 'NAME').text()
if (!frames.containsKey(imgName)) {
printWarning "full screen image '$imgName' not found; skipping set_fullscreen."
return
}
outIndented("loadFrameImg(PF${humanNameToSymbol(imgName, false)})\n")
}
def packClrPortrait(blk)
{
assert blk.field.size() == 0

View File

@ -27,7 +27,7 @@ import gamelib
predef calcPlayerArmor, rdkey, initHeap, scriptCombat, makeModifier
predef giveItemToPlayer, takeItemFromPlayer, playerHasItem, getStat, setStat
predef setGameFlag, getGameFlag, scriptSetAvatar, parseDecWithDefault, readStr
predef addPlayerToParty, removePlayerFromParty, partyHasPlayer
predef addPlayerToParty, removePlayerFromParty, partyHasPlayer, loadFrameImg
/////////// Shared string constants //////////////

View File

@ -49,7 +49,7 @@ word global // the global heap object, from which all live objects must be reac
///////////////////////////////////////////////////////////////////////////////////////////////////
// Predefined functions, for circular calls or out-of-order calls
predef setWindow2, initCmds, nextAnimFrame, checkEncounter, doCombat, clearPortrait, showMapName
predef doRender, playerDeath, startGame, loadFrameImg, showAnimFrame, finalWin
predef doRender, playerDeath, startGame, showAnimFrame, finalWin
///////////////////////////////////////////////////////////////////////////////////////////////////
// Global variables
@ -1084,13 +1084,19 @@ end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Load the Frame Image, and lock it.
def loadFrameImg(img)
export def loadFrameImg(img)
// Skip redundant reload
if frameLoaded == img; return; fin
// Free prev img and/or portrait (if any)
clearPortrait()
// Make room in aux mem by throwing out textures
if renderLoaded
flipToPage1()
texControl(0)
fin
// Load the image data into aux mem
auxMmgr(START_LOAD, 1) // partition 1 is where full screen images live
curFullscreenImg = auxMmgr(QUEUE_LOAD, img<<8 | RES_TYPE_SCREEN)
@ -1273,6 +1279,14 @@ def scanScripts(x, y)
loop
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def loadMainFrameImg()
mmgr(START_LOAD, 1) // partition 1 is where code lives
loadFrameImg(mapIs3D+2)
auxMmgr(FREE_MEMORY, curFullscreenImg)
curFullscreenImg = NULL
end
///////////////////////////////////////////////////////////////////////////////////////////////////
// Load code and data, set up everything to display a 2D or 3D map
def initMap(x, y, dir)
@ -1285,10 +1299,7 @@ def initMap(x, y, dir)
mmgr(RESET_MEMORY, 0)
// Load the frame image, then raycaster or tile engine
mmgr(START_LOAD, 1) // partition 1 is where code lives
loadFrameImg(mapIs3D+2)
auxMmgr(FREE_MEMORY, curFullscreenImg)
curFullscreenImg = NULL
loadMainFrameImg()
mmgr(SET_MEM_TARGET, displayEngine)
if mapIs3D
mmgr(QUEUE_LOAD, CODE_RENDER<<8 | RES_TYPE_CODE)
@ -1366,13 +1377,13 @@ export def clearPortrait()
if curPortrait
auxMmgr(FREE_MEMORY, curPortrait)
curPortrait = NULL
needRender = TRUE
fin
if curFullscreenImg
auxMmgr(FREE_MEMORY, curFullscreenImg)
curFullscreenImg = NULL
needRender = TRUE
loadMainFrameImg()
fin
needRender = TRUE
end
///////////////////////////////////////////////////////////////////////////////////////////////////
@ -1861,7 +1872,7 @@ def loadEngine(moduleNum)
if curEngine; fatal("dblEng"); fin
clearPortrait()
flipToPage1()
if renderLoaded; texControl(0); fin
texControl(0)
mmgr(START_LOAD, 1) // code is in partition 1
curEngine = mmgr(QUEUE_LOAD, moduleNum<<8 | RES_TYPE_MODULE)
mmgr(FINISH_LOAD, 0)