[colobot] 325/390: Made example programs not directly runnable (#450)
Didier Raboud
odyx at moszumanska.debian.org
Fri Jun 12 14:22:00 UTC 2015
This is an automated email from the git hooks/post-receive script.
odyx pushed a commit to branch upstream/latest
in repository colobot.
commit df4cb110b5f3ccc7831ea36fafcff51f47a43053
Author: krzys-h <krzys_h at interia.pl>
Date: Fri Apr 17 22:39:57 2015 +0200
Made example programs not directly runnable (#450)
---
po/colobot.pot | 3 +++
po/de.po | 3 +++
po/fr.po | 3 +++
po/pl.po | 3 +++
po/ru.po | 3 +++
src/common/restext.cpp | 1 +
src/common/restext.h | 1 +
src/object/brain.cpp | 16 ++++++++++++----
src/object/brain.h | 1 +
src/object/robotmain.cpp | 2 ++
src/ui/studio.cpp | 16 ++++++++++++++--
11 files changed, 46 insertions(+), 6 deletions(-)
diff --git a/po/colobot.pot b/po/colobot.pot
index a1893f3..abf3f33 100644
--- a/po/colobot.pot
+++ b/po/colobot.pot
@@ -186,6 +186,9 @@ msgstr ""
msgid "This program is read-only, clone it to edit"
msgstr ""
+msgid "This is example code that cannot be run directly"
+msgstr ""
+
msgid "\\b;List of objects\n"
msgstr ""
diff --git a/po/de.po b/po/de.po
index 440f94a..3d34c65 100644
--- a/po/de.po
+++ b/po/de.po
@@ -1486,6 +1486,9 @@ msgstr "Diese Klasse gibt es schon"
msgid "This class does not exist"
msgstr "Diese Klasse existiert nicht"
+msgid "This is example code that cannot be run directly"
+msgstr ""
+
msgid "This is not a member of this class"
msgstr "Dieses Element gibt es nicht in dieser Klasse"
diff --git a/po/fr.po b/po/fr.po
index 59f72a9..9f1d58a 100644
--- a/po/fr.po
+++ b/po/fr.po
@@ -1481,6 +1481,9 @@ msgstr "Cette classe existe déjà"
msgid "This class does not exist"
msgstr "Cette classe n'existe pas"
+msgid "This is example code that cannot be run directly"
+msgstr ""
+
msgid "This is not a member of this class"
msgstr "Cet élément n'existe pas dans cette classe"
diff --git a/po/pl.po b/po/pl.po
index 1b8cb52..7b9108b 100644
--- a/po/pl.po
+++ b/po/pl.po
@@ -1484,6 +1484,9 @@ msgstr "Taka klasa już istnieje"
msgid "This class does not exist"
msgstr "Taka klasa nie istnieje"
+msgid "This is example code that cannot be run directly"
+msgstr "To jest przykładowy kod którego nie można uruchomić bezpośrednio"
+
msgid "This is not a member of this class"
msgstr "To nie jest obiekt tej klasy"
diff --git a/po/ru.po b/po/ru.po
index 6748f4a..d69d408 100644
--- a/po/ru.po
+++ b/po/ru.po
@@ -1482,6 +1482,9 @@ msgstr "Этот класс уже существует"
msgid "This class does not exist"
msgstr "Этот класс не существует"
+msgid "This is example code that cannot be run directly"
+msgstr ""
+
msgid "This is not a member of this class"
msgstr "Это не член этого класса"
diff --git a/src/common/restext.cpp b/src/common/restext.cpp
index ebdc359..952076f 100644
--- a/src/common/restext.cpp
+++ b/src/common/restext.cpp
@@ -122,6 +122,7 @@ void InitializeRestext()
stringsText[RT_STUDIO_CLONED] = TR("Program cloned");
stringsText[RT_PROGRAM_READONLY] = TR("This program is read-only, clone it to edit");
+ stringsText[RT_PROGRAM_EXAMPLE] = TR("This is example code that cannot be run directly");
stringsText[RT_SATCOM_LIST] = TR("\\b;List of objects\n");
stringsText[RT_SATCOM_BOT] = TR("\\b;Robots\n");
diff --git a/src/common/restext.h b/src/common/restext.h
index 6fb9a01..9b3641e 100644
--- a/src/common/restext.h
+++ b/src/common/restext.h
@@ -118,6 +118,7 @@ enum ResTextType
RT_STUDIO_CLONED = 123,
RT_PROGRAM_READONLY = 130,
+ RT_PROGRAM_EXAMPLE = 131,
RT_SATCOM_LIST = 140,
RT_SATCOM_BOT = 141,
diff --git a/src/object/brain.cpp b/src/object/brain.cpp
index 5b42e34..55303d0 100644
--- a/src/object/brain.cpp
+++ b/src/object/brain.cpp
@@ -2311,7 +2311,7 @@ void CBrain::UpdateInterface()
EnableInterface(pw, EVENT_OBJECT_PROGLIST, bEnable && !m_bTraceRecord);
EnableInterface(pw, EVENT_OBJECT_PROGADD, m_currentProgram == nullptr);
EnableInterface(pw, EVENT_OBJECT_PROGREMOVE, m_currentProgram == nullptr && m_selScript < m_program.size() && !m_program[m_selScript]->readOnly);
- EnableInterface(pw, EVENT_OBJECT_PROGCLONE, m_currentProgram == nullptr);
+ EnableInterface(pw, EVENT_OBJECT_PROGCLONE, m_currentProgram == nullptr && m_selScript < m_program.size() && m_program[m_selScript]->runnable);
EnableInterface(pw, EVENT_OBJECT_PROGMOVEUP, m_currentProgram == nullptr && m_program.size() >= 2 && m_selScript > 0);
EnableInterface(pw, EVENT_OBJECT_PROGMOVEDOWN,m_currentProgram == nullptr && m_program.size() >= 2 && m_selScript < m_program.size()-1);
EnableInterface(pw, EVENT_OBJECT_LEFT, bEnable);
@@ -2460,10 +2460,17 @@ void CBrain::UpdateInterface()
bRun = false;
if ( m_selScript < m_program.size() )
{
- m_program[m_selScript]->script->GetTitle(title);
- if ( title[0] != 0 )
+ if(m_program[m_selScript]->runnable)
{
- bRun = true;
+ m_program[m_selScript]->script->GetTitle(title);
+ if ( title[0] != 0 )
+ {
+ bRun = true;
+ }
+ }
+ else
+ {
+ bRun = false;
}
}
if ( !bEnable && m_currentProgram == nullptr ) bRun = false;
@@ -3127,6 +3134,7 @@ Program* CBrain::AddProgram()
Program* program = new Program();
program->script = new CScript(m_object, &m_secondaryTask);
program->readOnly = false;
+ program->runnable = true;
AddProgram(program);
return program;
}
diff --git a/src/object/brain.h b/src/object/brain.h
index 143f177..d8d897c 100644
--- a/src/object/brain.h
+++ b/src/object/brain.h
@@ -79,6 +79,7 @@ struct Program
CScript* script;
std::string filename;
bool readOnly;
+ bool runnable;
};
diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp
index e56ee09..d60bdcb 100644
--- a/src/object/robotmain.cpp
+++ b/src/object/robotmain.cpp
@@ -3637,10 +3637,12 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
{
std::string op = "script"+boost::lexical_cast<std::string>(i+1); // script1..script10
std::string opReadOnly = "scriptReadOnly"+boost::lexical_cast<std::string>(i+1); // scriptReadOnly1..scriptReadOnly10
+ std::string opRunnable = "scriptRunnable"+boost::lexical_cast<std::string>(i+1); // scriptRunnable1..scriptRunnable10
if(line->GetParam(op)->IsDefined()) {
Program* program = brain->AddProgram();
program->filename = "../"+line->GetParam(op)->AsPath("ai");
program->readOnly = line->GetParam(opReadOnly)->AsBool(true);
+ program->runnable = line->GetParam(opRunnable)->AsBool(strcmp(base, "exercises") || i+1 != 4); // TODO: I'd rather not have it hardcoded like that
loadedPrograms[i] = program;
}
diff --git a/src/ui/studio.cpp b/src/ui/studio.cpp
index ab69ed6..659d0c3 100644
--- a/src/ui/studio.cpp
+++ b/src/ui/studio.cpp
@@ -649,7 +649,12 @@ void CStudio::StartEditScript(CScript *script, std::string name, Program* progra
button = pw->CreateButton(pos, dim, 64+29, EVENT_STUDIO_STEP);
button->SetState(STATE_SHADOW);
- if(m_program->readOnly)
+ if(!m_program->runnable)
+ {
+ GetResource(RES_TEXT, RT_PROGRAM_EXAMPLE, res);
+ SetInfoText(res, false);
+ }
+ else if(m_program->readOnly)
{
GetResource(RES_TEXT, RT_PROGRAM_READONLY, res);
SetInfoText(res, false);
@@ -1003,13 +1008,20 @@ void CStudio::UpdateButtons()
edit->SetHighlightCap(true);
}
+
+ button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_CLONE));
+ if ( button == 0 ) return;
+ button->SetState(STATE_ENABLE, m_program->runnable && !m_bRunning);
+
+
button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_COMPILE));
if ( button == 0 ) return;
- button->SetState(STATE_ENABLE, !m_bRunning);
+ button->SetState(STATE_ENABLE, m_program->runnable && !m_bRunning);
button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_RUN));
if ( button == 0 ) return;
button->SetIcon(m_bRunning?8:21); // stop/run
+ button->SetState(STATE_ENABLE, m_program->runnable || m_bRunning);
button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_REALTIME));
if ( button == 0 ) return;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/colobot.git
More information about the Pkg-games-commits
mailing list