2017-02-24 08:40:56 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
// Copyright (c) 2012 GarageGames, LLC
|
|
|
|
|
//
|
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
|
// of this software and associated documentation files (the "Software"), to
|
|
|
|
|
// deal in the Software without restriction, including without limitation the
|
|
|
|
|
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
|
|
|
// sell copies of the Software, and to permit persons to whom the Software is
|
|
|
|
|
// furnished to do so, subject to the following conditions:
|
|
|
|
|
//
|
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
|
//
|
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
|
|
|
// IN THE SOFTWARE.
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
// Message Sound
|
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
/*new SFXDescription(MessageBoxAudioDescription)
|
|
|
|
|
{
|
|
|
|
|
volume = 1.0;
|
|
|
|
|
isLooping = false;
|
|
|
|
|
is3D = false;
|
|
|
|
|
channel = $GuiAudioType;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
new SFXProfile(messageBoxBeep)
|
|
|
|
|
{
|
|
|
|
|
filename = "./messageBoxSound";
|
|
|
|
|
description = MessageBoxAudioDescription;
|
|
|
|
|
preload = true;
|
|
|
|
|
};*/
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------
|
|
|
|
|
// messageCallback
|
|
|
|
|
// Calls a callback passed to a message box.
|
|
|
|
|
//---------------------------------------------------------------------------------------------
|
|
|
|
|
function messageCallback(%dlg, %callback)
|
|
|
|
|
{
|
|
|
|
|
Canvas.popDialog(%dlg);
|
2020-05-20 22:19:52 +00:00
|
|
|
eval(%callback);
|
2017-02-24 08:40:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------
|
|
|
|
|
// MBSetText
|
|
|
|
|
// Sets the text of a message box and resizes it to accomodate the new string.
|
|
|
|
|
//---------------------------------------------------------------------------------------------
|
|
|
|
|
function MBSetText(%text, %frame, %msg)
|
|
|
|
|
{
|
|
|
|
|
// Get the extent of the text box.
|
|
|
|
|
%ext = %text.getExtent();
|
|
|
|
|
// Set the text in the center of the text box.
|
|
|
|
|
%text.setText("<just:center>" @ %msg);
|
|
|
|
|
// Force the textbox to resize itself vertically.
|
|
|
|
|
%text.forceReflow();
|
|
|
|
|
// Grab the new extent of the text box.
|
|
|
|
|
%newExtent = %text.getExtent();
|
|
|
|
|
|
|
|
|
|
// Get the vertical change in extent.
|
|
|
|
|
%deltaY = getWord(%newExtent, 1) - getWord(%ext, 1);
|
|
|
|
|
|
|
|
|
|
// Resize the window housing the text box.
|
|
|
|
|
%windowPos = %frame.getPosition();
|
|
|
|
|
%windowExt = %frame.getExtent();
|
|
|
|
|
%frame.resize(getWord(%windowPos, 0), getWord(%windowPos, 1) - (%deltaY / 2),
|
|
|
|
|
getWord(%windowExt, 0), getWord(%windowExt, 1) + %deltaY);
|
|
|
|
|
|
|
|
|
|
%frame.canMove = "0";
|
|
|
|
|
//%frame.canClose = "0";
|
|
|
|
|
%frame.resizeWidth = "0";
|
|
|
|
|
%frame.resizeHeight = "0";
|
|
|
|
|
%frame.canMinimize = "0";
|
|
|
|
|
%frame.canMaximize = "0";
|
|
|
|
|
|
|
|
|
|
//sfxPlayOnce( messageBoxBeep );
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-23 05:22:15 +00:00
|
|
|
function MessageBoxCtrl::onWake(%this)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-24 08:40:56 +00:00
|
|
|
//---------------------------------------------------------------------------------------------
|
|
|
|
|
// Various message box display functions. Each one takes a window title, a message, and a
|
|
|
|
|
// callback for each button.
|
|
|
|
|
//---------------------------------------------------------------------------------------------
|
|
|
|
|
|
2020-05-20 22:19:52 +00:00
|
|
|
//MessageBoxOK("Test", "This is a test message box", "echo(\"Uhhhhhawhat?\"");
|
2017-02-24 08:40:56 +00:00
|
|
|
function MessageBoxOK(%title, %message, %callback)
|
|
|
|
|
{
|
2020-05-20 22:19:52 +00:00
|
|
|
Canvas.pushDialog(MessageBoxDlg);
|
|
|
|
|
MessageBoxTitleText.text = %title;
|
|
|
|
|
|
2020-07-23 21:26:38 +00:00
|
|
|
MessageBoxOCButtonHolder.hidden = true;
|
|
|
|
|
MessageBoxYNCButtonHolder.hidden = true;
|
|
|
|
|
MessageBoxOKButtonHolder.hidden = false;
|
2020-05-20 22:19:52 +00:00
|
|
|
|
2020-07-23 21:26:38 +00:00
|
|
|
MessageBoxOKButtonHolder-->OKButton.set("btn_a", "Return", "OK", "MessageCallback(MessageBoxDlg,MessageBoxDlg.callback);");
|
2020-07-23 05:22:15 +00:00
|
|
|
|
2020-07-25 06:29:25 +00:00
|
|
|
MessageBoxCtrl.originalMenuInputContainer = $activeMenuButtonContainer;
|
2020-07-23 21:26:38 +00:00
|
|
|
MessageBoxOKButtonHolder.setActive();
|
2020-05-20 22:19:52 +00:00
|
|
|
|
|
|
|
|
MBSetText(MessageBoxText, MessageBoxCtrl, %message);
|
|
|
|
|
MessageBoxDlg.callback = %callback;
|
2017-02-24 08:40:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function MessageBoxOKDlg::onSleep( %this )
|
|
|
|
|
{
|
|
|
|
|
%this.callback = "";
|
2020-07-25 06:29:25 +00:00
|
|
|
MessageBoxCtrl.originalMenuInputContainer.setActive();
|
2017-02-24 08:40:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function MessageBoxOKCancel(%title, %message, %callback, %cancelCallback)
|
|
|
|
|
{
|
2020-05-20 22:19:52 +00:00
|
|
|
Canvas.pushDialog(MessageBoxDlg);
|
|
|
|
|
MessageBoxTitleText.text = %title;
|
|
|
|
|
|
2020-07-23 21:26:38 +00:00
|
|
|
MessageBoxOCButtonHolder.hidden = false;
|
|
|
|
|
MessageBoxYNCButtonHolder.hidden = true;
|
|
|
|
|
MessageBoxOKButtonHolder.hidden = true;
|
2020-05-20 22:19:52 +00:00
|
|
|
|
2020-07-23 21:26:38 +00:00
|
|
|
MessageBoxOCButtonHolder-->OKButton.set("btn_a", "Return", "OK", "MessageCallback(MessageBoxDlg,MessageBoxDlg.callback);");
|
|
|
|
|
MessageBoxOCButtonHolder-->CancelButton.set("btn_b", "Escape", "Cancel", "MessageCallback(MessageBoxDlg,MessageBoxDlg.cancelCallback);");
|
|
|
|
|
|
2020-07-25 06:29:25 +00:00
|
|
|
MessageBoxCtrl.originalMenuInputContainer = $activeMenuButtonContainer;
|
2020-07-23 21:26:38 +00:00
|
|
|
MessageBoxOCButtonHolder.setActive();
|
2020-05-20 22:19:52 +00:00
|
|
|
|
|
|
|
|
MBSetText(MessageBoxText, MessageBoxCtrl, %message);
|
|
|
|
|
MessageBoxDlg.callback = %callback;
|
|
|
|
|
MessageBoxDlg.cancelCallback = %cancelCallback;
|
2017-02-24 08:40:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function MessageBoxOKCancelDlg::onSleep( %this )
|
|
|
|
|
{
|
|
|
|
|
%this.callback = "";
|
2020-07-25 06:29:25 +00:00
|
|
|
MessageBoxCtrl.originalMenuInputContainer.setActive();
|
2017-02-24 08:40:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function MessageBoxOKCancelDetails(%title, %message, %details, %callback, %cancelCallback)
|
|
|
|
|
{
|
|
|
|
|
if(%details $= "")
|
|
|
|
|
{
|
|
|
|
|
MBOKCancelDetailsButton.setVisible(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MBOKCancelDetailsScroll.setVisible(false);
|
|
|
|
|
|
|
|
|
|
MBOKCancelDetailsFrame.setText( %title );
|
|
|
|
|
|
|
|
|
|
Canvas.pushDialog(MessageBoxOKCancelDetailsDlg);
|
|
|
|
|
MBSetText(MBOKCancelDetailsText, MBOKCancelDetailsFrame, %message);
|
|
|
|
|
MBOKCancelDetailsInfoText.setText(%details);
|
|
|
|
|
|
|
|
|
|
%textExtent = MBOKCancelDetailsText.getExtent();
|
|
|
|
|
%textExtentY = getWord(%textExtent, 1);
|
|
|
|
|
%textPos = MBOKCancelDetailsText.getPosition();
|
|
|
|
|
%textPosY = getWord(%textPos, 1);
|
|
|
|
|
|
|
|
|
|
%extentY = %textPosY + %textExtentY + 65;
|
|
|
|
|
|
|
|
|
|
MBOKCancelDetailsInfoText.setExtent(285, 128);
|
|
|
|
|
|
|
|
|
|
MBOKCancelDetailsFrame.setExtent(300, %extentY);
|
|
|
|
|
|
|
|
|
|
MessageBoxOKCancelDetailsDlg.callback = %callback;
|
|
|
|
|
MessageBoxOKCancelDetailsDlg.cancelCallback = %cancelCallback;
|
|
|
|
|
|
|
|
|
|
MBOKCancelDetailsFrame.defaultExtent = MBOKCancelDetailsFrame.getExtent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function MBOKCancelDetailsToggleInfoFrame()
|
|
|
|
|
{
|
|
|
|
|
if(!MBOKCancelDetailsScroll.isVisible())
|
|
|
|
|
{
|
|
|
|
|
MBOKCancelDetailsScroll.setVisible(true);
|
|
|
|
|
MBOKCancelDetailsText.forceReflow();
|
|
|
|
|
%textExtent = MBOKCancelDetailsText.getExtent();
|
|
|
|
|
%textExtentY = getWord(%textExtent, 1);
|
|
|
|
|
%textPos = MBOKCancelDetailsText.getPosition();
|
|
|
|
|
%textPosY = getWord(%textPos, 1);
|
|
|
|
|
|
|
|
|
|
%verticalStretch = %textExtentY;
|
|
|
|
|
|
|
|
|
|
if((%verticalStretch > 260) || (%verticalStretch < 0))
|
|
|
|
|
%verticalStretch = 260;
|
|
|
|
|
|
|
|
|
|
%extent = MBOKCancelDetailsFrame.defaultExtent;
|
|
|
|
|
%height = getWord(%extent, 1);
|
|
|
|
|
|
|
|
|
|
%posY = %textPosY + %textExtentY + 10;
|
|
|
|
|
%posX = getWord(MBOKCancelDetailsScroll.getPosition(), 0);
|
|
|
|
|
MBOKCancelDetailsScroll.setPosition(%posX, %posY);
|
|
|
|
|
MBOKCancelDetailsScroll.setExtent(getWord(MBOKCancelDetailsScroll.getExtent(), 0), %verticalStretch);
|
|
|
|
|
MBOKCancelDetailsFrame.setExtent(300, %height + %verticalStretch + 10);
|
|
|
|
|
} else
|
|
|
|
|
{
|
|
|
|
|
%extent = MBOKCancelDetailsFrame.defaultExtent;
|
|
|
|
|
%width = getWord(%extent, 0);
|
|
|
|
|
%height = getWord(%extent, 1);
|
|
|
|
|
MBOKCancelDetailsFrame.setExtent(%width, %height);
|
|
|
|
|
MBOKCancelDetailsScroll.setVisible(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function MessageBoxOKCancelDetailsDlg::onSleep( %this )
|
|
|
|
|
{
|
|
|
|
|
%this.callback = "";
|
2020-07-25 06:29:25 +00:00
|
|
|
MessageBoxCtrl.originalMenuInputContainer.setActive();
|
2017-02-24 08:40:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function MessageBoxYesNo(%title, %message, %yesCallback, %noCallback)
|
|
|
|
|
{
|
2020-05-20 22:19:52 +00:00
|
|
|
Canvas.pushDialog(MessageBoxDlg);
|
|
|
|
|
MessageBoxTitleText.text = %title;
|
|
|
|
|
|
2020-07-23 21:26:38 +00:00
|
|
|
MessageBoxOCButtonHolder.hidden = false;
|
|
|
|
|
MessageBoxYNCButtonHolder.hidden = true;
|
|
|
|
|
MessageBoxOKButtonHolder.hidden = true;
|
2020-05-20 22:19:52 +00:00
|
|
|
|
2020-07-23 21:26:38 +00:00
|
|
|
MessageBoxOCButtonHolder-->OKButton.set("btn_a", "Return", "Yes", "MessageCallback(MessageBoxDlg,MessageBoxDlg.yesCallBack);");
|
|
|
|
|
MessageBoxOCButtonHolder-->CancelButton.set("btn_b", "Escape", "No", "MessageCallback(MessageBoxDlg,MessageBoxDlg.noCallback);");
|
2020-07-23 05:22:15 +00:00
|
|
|
|
2020-07-25 06:29:25 +00:00
|
|
|
MessageBoxCtrl.originalMenuInputContainer = $activeMenuButtonContainer;
|
2020-07-23 21:26:38 +00:00
|
|
|
MessageBoxOCButtonHolder.setActive();
|
2020-05-20 22:19:52 +00:00
|
|
|
|
|
|
|
|
MBSetText(MessageBoxText, MessageBoxCtrl, %message);
|
|
|
|
|
MessageBoxDlg.yesCallBack = %yesCallback;
|
|
|
|
|
MessageBoxDlg.noCallback = %noCallback;
|
2017-02-24 08:40:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function MessageBoxYesNoCancel(%title, %message, %yesCallback, %noCallback, %cancelCallback)
|
|
|
|
|
{
|
2020-05-20 22:19:52 +00:00
|
|
|
Canvas.pushDialog(MessageBoxDlg);
|
|
|
|
|
MessageBoxTitleText.text = %title;
|
|
|
|
|
|
2020-07-23 21:26:38 +00:00
|
|
|
MessageBoxOCButtonHolder.hidden = true;
|
|
|
|
|
MessageBoxYNCButtonHolder.hidden = false;
|
|
|
|
|
MessageBoxOKButtonHolder.hidden = true;
|
2020-07-23 05:22:15 +00:00
|
|
|
|
2020-07-23 21:26:38 +00:00
|
|
|
MessageBoxYNCButtonHolder-->yesButton.set("btn_a", "Return", "Yes", "MessageCallback(MessageBoxDlg,MessageBoxDlg.yesCallBack);");
|
|
|
|
|
MessageBoxYNCButtonHolder-->noButton.set("btn_x", "backspace", "No", "MessageCallback(MessageBoxDlg,MessageBoxDlg.noCallback);");
|
|
|
|
|
MessageBoxYNCButtonHolder-->cancelButton.set("btn_b", "Escape", "No", "MessageCallback(MessageBoxDlg,MessageBoxDlg.cancelCallback);");
|
2020-05-20 22:19:52 +00:00
|
|
|
|
2020-07-25 06:29:25 +00:00
|
|
|
MessageBoxCtrl.originalMenuInputContainer = $activeMenuButtonContainer;
|
2020-07-23 21:26:38 +00:00
|
|
|
MessageBoxYNCButtonHolder.setActive();
|
2020-05-20 22:19:52 +00:00
|
|
|
|
|
|
|
|
MBSetText(MessageBoxText, MessageBoxCtrl, %message);
|
|
|
|
|
MessageBoxDlg.yesCallBack = %yesCallback;
|
|
|
|
|
MessageBoxDlg.noCallback = %noCallback;
|
|
|
|
|
MessageBoxDlg.cancelCallback = %cancelCallback;
|
2017-02-24 08:40:56 +00:00
|
|
|
}
|
|
|
|
|
|
2020-05-20 22:19:52 +00:00
|
|
|
function MessageBoxDlg::onSleep( %this )
|
2017-02-24 08:40:56 +00:00
|
|
|
{
|
2020-05-20 22:19:52 +00:00
|
|
|
%this.callback = "";
|
|
|
|
|
%this.cancelCallback = "";
|
2017-02-24 08:40:56 +00:00
|
|
|
%this.yesCallback = "";
|
|
|
|
|
%this.noCallback = "";
|
2020-05-20 22:19:52 +00:00
|
|
|
%this.cancelCallback = "";
|
2020-07-25 06:29:25 +00:00
|
|
|
MessageBoxCtrl.originalMenuInputContainer.setActive();
|
2017-02-24 08:40:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------
|
|
|
|
|
// MessagePopup
|
|
|
|
|
// Displays a message box with no buttons. Disappears after %delay milliseconds.
|
|
|
|
|
//---------------------------------------------------------------------------------------------
|
|
|
|
|
function MessagePopup(%title, %message, %delay)
|
|
|
|
|
{
|
2020-05-20 22:19:52 +00:00
|
|
|
Canvas.pushDialog(MessageBoxDlg);
|
|
|
|
|
MessageBoxTitleText.text = %title;
|
|
|
|
|
MBSetText(MessageBoxText, MessageBoxCtrl, %message);
|
|
|
|
|
|
2017-02-24 08:40:56 +00:00
|
|
|
if (%delay !$= "")
|
|
|
|
|
schedule(%delay, 0, CloseMessagePopup);
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-20 22:19:52 +00:00
|
|
|
function CloseMessagePopup()
|
|
|
|
|
{
|
|
|
|
|
Canvas.popDialog(MessageBoxDlg);
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-24 08:40:56 +00:00
|
|
|
//---------------------------------------------------------------------------------------------
|
|
|
|
|
// IODropdown
|
|
|
|
|
// By passing in a simgroup or simset, the user will be able to choose a child of that group
|
|
|
|
|
// through a guiPopupMenuCtrl
|
|
|
|
|
//---------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
function IODropdown(%title, %message, %simgroup, %callback, %cancelCallback)
|
|
|
|
|
{
|
|
|
|
|
IODropdownFrame.text = %title;
|
|
|
|
|
Canvas.pushDialog(IODropdownDlg);
|
|
|
|
|
MBSetText(IODropdownText, IODropdownFrame, %message);
|
|
|
|
|
|
|
|
|
|
if(isObject(%simgroup))
|
|
|
|
|
{
|
|
|
|
|
for(%i = 0; %i < %simgroup.getCount(); %i++)
|
|
|
|
|
IODropdownMenu.add(%simgroup.getObject(%i).getName());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IODropdownMenu.sort();
|
|
|
|
|
IODropdownMenu.setFirstSelected(0);
|
|
|
|
|
|
|
|
|
|
IODropdownDlg.callback = %callback;
|
|
|
|
|
IODropdownDlg.cancelCallback = %cancelCallback;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function IODropdownDlg::onSleep( %this )
|
|
|
|
|
{
|
|
|
|
|
%this.callback = "";
|
|
|
|
|
%this.cancelCallback = "";
|
|
|
|
|
IODropdownMenu.clear();
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-20 22:19:52 +00:00
|
|
|
//The # in the function passed replaced with the output
|
|
|
|
|
//of the preset menu.
|
|
|
|
|
function IOCallback(%dlg, %callback)
|
2017-02-24 08:40:56 +00:00
|
|
|
{
|
2020-05-20 22:19:52 +00:00
|
|
|
%id = IODropdownMenu.getSelected();
|
|
|
|
|
%text = IODropdownMenu.getTextById(%id);
|
|
|
|
|
%callback = strreplace(%callback, "#", %text);
|
|
|
|
|
eval(%callback);
|
|
|
|
|
|
|
|
|
|
Canvas.popDialog(%dlg);
|
2017-02-24 08:40:56 +00:00
|
|
|
}
|