- added option to toggle lua sandbox

This commit is contained in:
Mark Vejvoda 2012-10-16 21:08:45 +00:00
parent 9634ba58d4
commit e295ccc5a1
2 changed files with 84 additions and 2 deletions

View File

@ -453,8 +453,23 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
checkBoxTimeDisplay.setValue(config.getBool("TimeDisplay","true"));
currentLine-=lineOffset;
labelLuaDisableSecuritySandbox.registerGraphicComponent(containerName,"labelLuaDisableSecuritySandbox");
labelLuaDisableSecuritySandbox.init(currentLabelStart ,currentLine);
labelLuaDisableSecuritySandbox.setText(lang.get("LuaDisableSecuritySandbox"));
checkBoxLuaDisableSecuritySandbox.registerGraphicComponent(containerName,"checkBoxLuaDisableSecuritySandbox");
checkBoxLuaDisableSecuritySandbox.init(currentColumnStart ,currentLine );
checkBoxLuaDisableSecuritySandbox.setValue(config.getBool("DisableLuaSandbox","false"));
luaMessageBox.registerGraphicComponent(containerName,"luaMessageBox");
luaMessageBox.init(lang.get("Yes"),lang.get("No"));
luaMessageBox.setEnabled(false);
luaMessageBoxState=0;
currentLine-=lineOffset;
labelNetworkSettings.registerGraphicComponent(containerName,"labelNetworkSettingsSection");
labelNetworkSettings.init(currentLabelStart+captionOffset, currentLine);
labelNetworkSettings.setFont(CoreData::getInstance().getMenuFontVeryBig());
@ -610,6 +625,7 @@ void MenuStateOptions::reloadUI() {
console.resetFonts();
mainMessageBox.init(lang.get("Ok"));
luaMessageBox.init(lang.get("Yes"),lang.get("No"));
labelAudioSection.setFont(CoreData::getInstance().getMenuFontVeryBig());
labelAudioSection.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D());
@ -678,6 +694,8 @@ void MenuStateOptions::reloadUI() {
labelChatStaysActive.setText(lang.get("ChatStaysActive"));
labelTimeDisplay.setText(lang.get("TimeDisplay"));
labelLuaDisableSecuritySandbox.setText(lang.get("LuaDisableSecuritySandbox"));
labelRainEffect.setText(lang.get("RainEffect"));
labelVideos.setText(lang.get("EnableVideos"));
@ -751,7 +769,20 @@ void MenuStateOptions::showMessageBox(const string &text, const string &header,
}
}
void MenuStateOptions::showLuaMessageBox(const string &text, const string &header, bool toggle) {
if(!toggle) {
luaMessageBox.setEnabled(false);
}
if(!luaMessageBox.getEnabled()){
luaMessageBox.setText(text);
luaMessageBox.setHeader(header);
luaMessageBox.setEnabled(true);
}
else{
luaMessageBox.setEnabled(false);
}
}
void MenuStateOptions::mouseClick(int x, int y, MouseButton mouseButton){
@ -777,6 +808,28 @@ void MenuStateOptions::mouseClick(int x, int y, MouseButton mouseButton){
}
}
}
else if(luaMessageBox.getEnabled()){
int button= 0;
if(luaMessageBox.mouseClick(x, y, button)) {
checkBoxLuaDisableSecuritySandbox.setValue(false);
soundRenderer.playFx(coreData.getClickSoundA());
if(button == 0) {
if(luaMessageBoxState == 1) {
checkBoxLuaDisableSecuritySandbox.setValue(true);
}
}
luaMessageBox.setEnabled(false);
}
}
else if(checkBoxLuaDisableSecuritySandbox.mouseClick(x, y)) {
if(checkBoxLuaDisableSecuritySandbox.getValue() == true) {
checkBoxLuaDisableSecuritySandbox.setValue(false);
luaMessageBoxState=1;
Lang &lang= Lang::getInstance();
showLuaMessageBox(lang.get("LuaDisableSecuritySandboxWaring"), lang.get("Question"), false);
}
}
else if(buttonOk.mouseClick(x, y)){
soundRenderer.playFx(coreData.getClickSoundA());
@ -904,6 +957,8 @@ void MenuStateOptions::mouseClick(int x, int y, MouseButton mouseButton){
checkBoxChatStaysActive.mouseClick(x, y);
checkBoxTimeDisplay.mouseClick(x, y);
checkBoxLuaDisableSecuritySandbox.mouseClick(x, y);
checkBoxRainEffect.mouseClick(x,y);
checkBoxRainEffectMenu.mouseClick(x,y);
@ -913,8 +968,12 @@ void MenuStateOptions::mouseClick(int x, int y, MouseButton mouseButton){
void MenuStateOptions::mouseMove(int x, int y, const MouseState *ms){
if (mainMessageBox.getEnabled()) {
mainMessageBox.mouseMove(x, y);
}
mainMessageBox.mouseMove(x, y);
}
if (luaMessageBox.getEnabled()) {
luaMessageBox.mouseMove(x, y);
}
buttonOk.mouseMove(x, y);
buttonAbort.mouseMove(x, y);
buttonAutoConfig.mouseMove(x, y);
@ -950,6 +1009,9 @@ void MenuStateOptions::mouseMove(int x, int y, const MouseState *ms){
checkBoxVisibleHud.mouseMove(x, y);
checkBoxChatStaysActive.mouseMove(x, y);
checkBoxTimeDisplay.mouseMove(x, y);
checkBoxLuaDisableSecuritySandbox.mouseMove(x, y);
checkBoxRainEffect.mouseMove(x, y);
checkBoxRainEffectMenu.mouseMove(x, y);
@ -1030,6 +1092,9 @@ void MenuStateOptions::render(){
if(mainMessageBox.getEnabled()){
renderer.renderMessageBox(&mainMessageBox);
}
else if(luaMessageBox.getEnabled()){
renderer.renderMessageBox(&luaMessageBox);
}
else
{
renderer.renderButton(&buttonOk);
@ -1115,6 +1180,10 @@ void MenuStateOptions::render(){
renderer.renderLabel(&labelVisibleHud);
renderer.renderLabel(&labelChatStaysActive);
renderer.renderLabel(&labelTimeDisplay);
renderer.renderLabel(&labelLuaDisableSecuritySandbox);
renderer.renderCheckBox(&checkBoxLuaDisableSecuritySandbox);
renderer.renderCheckBox(&checkBoxVisibleHud);
renderer.renderCheckBox(&checkBoxChatStaysActive);
renderer.renderCheckBox(&checkBoxTimeDisplay);
@ -1191,6 +1260,8 @@ void MenuStateOptions::saveConfig(){
config.setBool("ChatStaysActive", checkBoxChatStaysActive.getValue());
config.setBool("TimeDisplay", checkBoxTimeDisplay.getValue());
config.setBool("DisableLuaSandbox", checkBoxLuaDisableSecuritySandbox.getValue());
config.setBool("RainEffect", checkBoxRainEffect.getValue());
config.setBool("RainEffectMenu", checkBoxRainEffectMenu.getValue());
@ -1211,6 +1282,10 @@ void MenuStateOptions::saveConfig(){
config.save();
if(config.getBool("DisableLuaSandbox","false") == true) {
LuaScript::setDisableSandbox(true);
}
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
soundRenderer.stopAllSounds();
program->stopSoundSystem();

View File

@ -138,6 +138,12 @@ private:
GraphicLabel labelVideos;
GraphicCheckBox checkBoxVideos;
GraphicLabel labelLuaDisableSecuritySandbox;
GraphicCheckBox checkBoxLuaDisableSecuritySandbox;
GraphicMessageBox luaMessageBox;
int luaMessageBoxState;
map<string,string> languageList;
public:
@ -157,6 +163,7 @@ private:
void saveConfig();
void setActiveInputLable(GraphicLabel* newLable);
void showMessageBox(const string &text, const string &header, bool toggle);
void showLuaMessageBox(const string &text, const string &header, bool toggle);
};
}}//end namespace