Mission Preview Image
by Bill Vee · 08/01/2008 (10:26 am) · 5 comments
I was inspired by Konrad Kiss's resource for Unique loading screen for each mission.
This resource will allow you to display an image of a mission when you select it from the startMissionGui.gui.
Open scriptsAndAssets/client/ui/startMissionGui.gui and after
Add
You can also add it with the gui editor just as long as you place it on the guicontrol that has the GuiTextListCtrl(SM_missionList) and as long as you name the GuiBitmapCtrl Preview_image.
Next add to the bottom of the file
All done with startMissionGui.gui.
Now We need an easy way to save our mission previews.
I prefer to use an in game screenshot of the mission itself.
Open common/gameScripts/screenshot.cs and add this to the bottom.
This will take a screenshot and give it the name of the current mission and place it in the mission folder for easy access.
All you need to do now is add a bind for it in common/gameScripts/common.cs
Just after
Add
Now start your game and goto your mission select menu and you should now have an image preview.
I have only tested this with TGEA 1.7.1 but it should work fine for TGE 1.4 or greater.
Enjoy.
This resource will allow you to display an image of a mission when you select it from the startMissionGui.gui.
Open scriptsAndAssets/client/ui/startMissionGui.gui and after
new GuiButtonCtrl() {
canSaveDynamicFields = "0";
Enabled = "1";
isContainer = "0";
Profile = "GuiButtonProfile";
HorizSizing = "right";
VertSizing = "bottom";
position = "10 272";
Extent = "127 23";
MinExtent = "8 8";
canSave = "1";
Visible = "1";
Command = "Canvas.setContent(mainMenuGui);";
hovertime = "1000";
text = "<< Back";
groupNum = "-1";
buttonType = "PushButton";
useMouseEvents = "0";
};Add
new GuiBitmapCtrl(Preview_image) {
canSaveDynamicFields = "0";
Enabled = "1";
isContainer = "0";
HorizSizing = "right";
VertSizing = "bottom";
position = "221 64";
Extent = "223 190";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
hovertime = "1000";
bitmap = "";
wrap = "0";
};You can also add it with the gui editor just as long as you place it on the guicontrol that has the GuiTextListCtrl(SM_missionList) and as long as you name the GuiBitmapCtrl Preview_image.
Next add to the bottom of the file
function SM_missionList::OnSelect( %this, %id, %text )
{
%mission = getField(SM_missionList.getRowTextById(%id), 0);
Preview_image.setBitmap("scriptsAndAssets/data/missions/loading_" @ %mission );
}All done with startMissionGui.gui.
Now We need an easy way to save our mission previews.
I prefer to use an in game screenshot of the mission itself.
Open common/gameScripts/screenshot.cs and add this to the bottom.
function doMissionScreenShot(%val)
{
if ((%val) || (%val $= ""))
{
%name = "scriptsAndAssets/data/missions/loading_" @ MissionInfo.name;
if (($pref::Video::screenShotFormat $= "JPEG") ||
($pref::video::screenShotFormat $= "JPG"))
screenShot(%name @ ".jpg", "JPEG");
else if($pref::Video::screenShotFormat $= "PNG")
screenShot(%name @ ".png", "PNG");
else
screenShot(%name @ ".png", "PNG");
}
}This will take a screenshot and give it the name of the current mission and place it in the mission folder for easy access.
All you need to do now is add a bind for it in common/gameScripts/common.cs
Just after
function initializeCommon()
{
// Not Reentrant
if( $commonInitialized == true )
return;
// Common keybindings.
GlobalActionMap.bind(keyboard, tilde, toggleConsole);
GlobalActionMap.bind(keyboard, "ctrl p", doScreenShot);Add
GlobalActionMap.bind(keyboard, "ctrl m", doMissionScreenShot);
Now start your game and goto your mission select menu and you should now have an image preview.
I have only tested this with TGEA 1.7.1 but it should work fine for TGE 1.4 or greater.
Enjoy.
About the author
#2
The GG site search didn't come up with it the first time I looked.
Enhanced StartMissionGui
08/01/2008 (11:46 am)
I didn't know till later but there appears to be a resource for this already.The GG site search didn't come up with it the first time I looked.
Enhanced StartMissionGui
#3
You might not have been first, but well done all the same.
08/01/2008 (7:14 pm)
I guess people now have a choice of mission preview resources!You might not have been first, but well done all the same.
#4
08/04/2008 (5:51 am)
Thanks Bill! I used your code to add a loading image to my loading GUI as opposed to the mission select GUI.
#5
08/07/2008 (2:10 am)
Nice... Man.... :D
Associate Konrad Kiss
Bitgap Games