[Orxonox-commit 5494] r10157 - in code/branches/storymodeHS14: data/gui/layouts data/gui/scripts src/orxonox/gametypes
maxima at orxonox.net
maxima at orxonox.net
Fri Dec 5 15:10:43 CET 2014
Author: maxima
Date: 2014-12-05 15:10:42 +0100 (Fri, 05 Dec 2014)
New Revision: 10157
Added:
code/branches/storymodeHS14/data/gui/layouts/CampaignMenu.layout
code/branches/storymodeHS14/data/gui/scripts/CampaignMenu.lua
code/branches/storymodeHS14/data/gui/scripts/campaign.txt
Modified:
code/branches/storymodeHS14/data/gui/layouts/SingleplayerMenu.layout
code/branches/storymodeHS14/data/gui/scripts/SingleplayerMenu.lua
code/branches/storymodeHS14/src/orxonox/gametypes/Mission.cc
Log:
Changes of Phillip. He couldn't upload himself. New Campaign Menu added.
Added: code/branches/storymodeHS14/data/gui/layouts/CampaignMenu.layout
===================================================================
--- code/branches/storymodeHS14/data/gui/layouts/CampaignMenu.layout (rev 0)
+++ code/branches/storymodeHS14/data/gui/layouts/CampaignMenu.layout 2014-12-05 14:10:42 UTC (rev 10157)
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<GUILayout >
+ <Window Type="MenuWidgets/StaticImage" Name="orxonox/CampaignBackground" >
+ <Property Name="FrameEnabled" Value="False" />
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1.0,0},{1.0,0}}" />
+ <Property Name="BackgroundEnabled" Value="False" />
+ <Window Type="MenuWidgets/Button" Name="orxonox/MissionOneButton" >
+ <Property Name="Text" Value="Mission 1" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.2875,0},{0.6,0},{0.3375,0}}" />
+ <Event Name="Clicked" Function="CampaignMenu.MissionOneButton_clicked"/>
+ </Window>
+ <Window Type="MenuWidgets/Button" Name="orxonox/MissionTwoButton" >
+ <Property Name="Text" Value="Mission 2" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.3625,0},{0.6,0},{0.4125,0}}" />
+ <Property Name="Disabled" Value="True" />
+ <Event Name="Clicked" Function="CampaignMenu.MissionTwoButton_clicked"/>
+ </Window>
+ <Window Type="MenuWidgets/Button" Name="orxonox/MissionThreeButton" >
+ <Property Name="Text" Value="Mission 3" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.4375,0},{0.6,0},{0.4875,0}}" />
+ <Property Name="Disabled" Value="True" />
+ <Event Name="Clicked" Function="CampaignMenu.MissionThreeButton_clicked"/>
+ </Window>
+ <Window Type="MenuWidgets/Button" Name="orxonox/MissionFourButton" >
+ <Property Name="Text" Value="Mission 4" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.5125,0},{0.6,0},{0.5625,0}}" />
+ <Property Name="Disabled" Value="True" />
+ <Event Name="Clicked" Function="CampaignMenu.MissionFourButton_clicked"/>
+ </Window>
+ <Window Type="MenuWidgets/Button" Name="orxonox/CampaignMenuBackButton" >
+ <Property Name="Text" Value="Back" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.7,0},{0.8,0},{0.85,0},{0.85,0}}" />
+ <Event Name="Clicked" Function="CampaignMenu.CampaignMenuBackButton_clicked"/>
+ </Window>
+ <Window Type="MenuWidgets/Button" Name="orxonox/CampaignMenuRefreshButton" >
+ <Property Name="Text" Value="Refresh" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.2,0},{0.8,0},{0.3,0},{0.85,0}}" />
+ <Event Name="Clicked" Function="CampaignMenu.CampaignMenuRefreshButton_clicked"/>
+ </Window>
+ <Window Type="MenuWidgets/StaticText" Name="orxonox/CampaignMenuCongratulation" >
+ <Property Name="Text" Value="Campaign Completed!!!" />
+ <Property Name="Visible" Value="False"/>
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="HorzFormatting" Value="HorzCentred" />
+ <Property Name="VertFormatting" Value="TopAligned" />
+ <Property Name="UnifiedMaxSize" Value="{{2,1},{2,1}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.15,0},{0.6,0},{0.2,0}}" />
+ </Window>
+ </Window>
+</GUILayout>
\ No newline at end of file
Modified: code/branches/storymodeHS14/data/gui/layouts/SingleplayerMenu.layout
===================================================================
--- code/branches/storymodeHS14/data/gui/layouts/SingleplayerMenu.layout 2014-12-04 16:16:20 UTC (rev 10156)
+++ code/branches/storymodeHS14/data/gui/layouts/SingleplayerMenu.layout 2014-12-05 14:10:42 UTC (rev 10157)
@@ -52,7 +52,13 @@
<Property Name="Text" Value="Back" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="UnifiedAreaRect" Value="{{0.6,0},{0.725,0},{0.75,0},{0.775,0}}" />
- <Event Name="Clicked" Function="SingleplayerMenu.SingleplayerBackButton_clicked"/>
+ <Event Name="Clicked" Function="SingleplayerMenu.SingleplayerBackButton_clicked"/>
</Window>
+ <Window Type="MenuWidgets/Button" Name="orxonox/CampaignButton" >
+ <Property Name="Text" Value="Campaign" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.8,0},{0.6,0},{0.85,0}}" />
+ <Event Name="Clicked" Function="SingleplayerMenu.CampaignButton_clicked"/>
+ </Window>
</Window>
</GUILayout>
Added: code/branches/storymodeHS14/data/gui/scripts/CampaignMenu.lua
===================================================================
--- code/branches/storymodeHS14/data/gui/scripts/CampaignMenu.lua (rev 0)
+++ code/branches/storymodeHS14/data/gui/scripts/CampaignMenu.lua 2014-12-05 14:10:42 UTC (rev 10157)
@@ -0,0 +1,136 @@
+--CampaignMenu.lua
+
+local P = createMenuSheet("CampaignMenu")
+
+function P.onLoad()
+
+ local MissionTwoButton = winMgr:getWindow("orxonox/MissionTwoButton")
+ if (P.CheckLevel("missionOne.oxw")) then
+ MissionTwoButton:setProperty("Disabled", "False")
+ end
+
+ local MissionThreeButton = winMgr:getWindow("orxonox/MissionThreeButton")
+ if (P.CheckLevel("fightInOurBack.oxw")) then
+ MissionThreeButton:setProperty("Disabled", "False")
+ end
+
+ local MissionFourButton = winMgr:getWindow("orxonox/MissionFourButton")
+ if (P.CheckLevel("pirateAttack.oxw")) then
+ MissionFourButton:setProperty("Disabled", "False")
+ end
+
+ local Completed = winMgr:getWindow("orxonox/CampaignMenuCongratulation")
+ if (P.CheckLevel("iJohnVane_TriptoArea51.oxw")) then
+ Completed:setProperty("Visible","True")
+ end
+end
+
+function P.GenerateHelperString(number)
+ local string = ""
+ while number > 1 do
+ string = string.." "
+ number = number-1
+ end
+ string = string.."."
+ return string
+end
+
+function P.FindLevel(filename)
+ local level = nil
+ local templevel = nil
+ local size = orxonox.LevelManager:getInstance():getNumberOfLevels()
+ local index = 0
+ while index < size do
+ templevel = orxonox.LevelManager:getInstance():getAvailableLevelListItem(index)
+ if(templevel:getXMLFilename()==filename) then
+ level = templevel
+ end
+ index=index+1
+ end
+ return level
+end
+
+function P.CheckLevel(filename)
+ local file = io.open("/home/pmao/pmao-extra-0/orxonox/storymodeHS14/data/gui/scripts/campaign.txt", "r+")
+ local index = 0
+ local returnvalue = false
+ local numberoflines = 58-string.len(filename)
+ local helpstringfalse = filename.." 0"..P.GenerateHelperString(numberoflines)
+ local helpstringtrue = filename.." 1"..P.GenerateHelperString(numberoflines)
+ while index < 100 do
+ local line = file:read()
+ if(line == helpstringfalse) then
+ returnvalue = false
+ break
+ end
+ if(line == helpstringtrue) then
+ returnvalue = true
+ break
+ end
+ index=index+1
+ end
+ io.close(file)
+ return returnvalue
+end
+
+function P.MissionOneButton_clicked(e)
+ local level = P.FindLevel("missionOne.oxw")
+ orxonox.execute("startGame " .. level:getXMLFilename())
+ hideAllMenuSheets()
+end
+
+function P.MissionTwoButton_clicked(e)
+ local level = P.FindLevel("fightInOurBack.oxw")
+ if (P.CheckLevel("missionOne.oxw")) then
+ orxonox.execute("startGame " .. level:getXMLFilename())
+ hideAllMenuSheets()
+ end
+end
+
+function P.MissionThreeButton_clicked(e)
+ local level = P.FindLevel("pirateAttack.oxw")
+ if (P.CheckLevel("fightInOurBack.oxw")) then
+ orxonox.execute("startGame " .. level:getXMLFilename())
+ hideAllMenuSheets()
+ else
+ hideMenuSheet(P.name)
+ end
+end
+
+function P.MissionFourButton_clicked(e)
+ local level = P.FindLevel("iJohnVane_TriptoArea51.oxw")
+ if (P.CheckLevel("pirateAttack.oxw")) then
+ orxonox.execute("startGame " .. level:getXMLFilename())
+ hideAllMenuSheets()
+ else
+ hideMenuSheet(P.name)
+ end
+end
+
+function P.CampaignMenuRefreshButton_clicked(e)
+ local MissionTwoButton = winMgr:getWindow("orxonox/MissionTwoButton")
+ if (P.CheckLevel("missionOne.oxw")) then
+ MissionTwoButton:setProperty("Disabled", "False")
+ end
+
+ local MissionThreeButton = winMgr:getWindow("orxonox/MissionThreeButton")
+ if (P.CheckLevel("fightInOurBack.oxw")) then
+ MissionThreeButton:setProperty("Disabled", "False")
+ end
+
+ local MissionFourButton = winMgr:getWindow("orxonox/MissionFourButton")
+ if (P.CheckLevel("pirateAttack.oxw")) then
+ MissionFourButton:setProperty("Disabled", "False")
+ end
+
+ local Completed = winMgr:getWindow("orxonox/CampaignMenuCongratulation")
+ if (P.CheckLevel("iJohnVane_TriptoArea51.oxw")) then
+ Completed:setProperty("Visible","True")
+ end
+end
+
+function P.CampaignMenuBackButton_clicked(e)
+ hideMenuSheet(P.name)
+end
+
+return P
\ No newline at end of file
Modified: code/branches/storymodeHS14/data/gui/scripts/SingleplayerMenu.lua
===================================================================
--- code/branches/storymodeHS14/data/gui/scripts/SingleplayerMenu.lua 2014-12-04 16:16:20 UTC (rev 10156)
+++ code/branches/storymodeHS14/data/gui/scripts/SingleplayerMenu.lua 2014-12-05 14:10:42 UTC (rev 10157)
@@ -1,7 +1,7 @@
-- SingleplayerMenu.lua
local P = createMenuSheet("SingleplayerMenu")
-P.loadAlong = {"ShipSelectionMenu"}
+P.loadAlong = {"ShipSelectionMenu","CampaignMenu"}
P.levelList = {}
P.activeTabIndexes = {}
P.scrollbarWidth = 13
@@ -18,11 +18,12 @@
P.createFilterTab("Presentations", "presentation")
P.createFilterTab("Tests", "test")
P.createFilterTab("Show All", nil)
+
-- update description and screenshot boxes
P.SingleplayerSelectionChanged()
- --buttons are arranged in a 1x3 matrix
+ --buttons are arranged in a 1x4 matrix
P:setButton(1, 1, {
["button"] = winMgr:getWindow("orxonox/SingleplayerStartButton"),
["callback"] = P.SingleplayerStartButton_clicked
@@ -37,6 +38,10 @@
["button"] = winMgr:getWindow("orxonox/SingleplayerBackButton"),
["callback"] = P.SingleplayerBackButton_clicked
})
+ P:setButton(1, 4,{
+ ["button"] = winMgr:getWindow("orxonox/CampaignButton"),
+ ["callback"] = P.CampaignButton_clicked
+ })
end
function P.createLevelList()
@@ -165,4 +170,8 @@
hideMenuSheet(P.name)
end
+function P.CampaignButton_clicked(e)
+ showMenuSheet("CampaignMenu", true)
+end
+
return P
Added: code/branches/storymodeHS14/data/gui/scripts/campaign.txt
===================================================================
--- code/branches/storymodeHS14/data/gui/scripts/campaign.txt (rev 0)
+++ code/branches/storymodeHS14/data/gui/scripts/campaign.txt 2014-12-05 14:10:42 UTC (rev 10157)
@@ -0,0 +1,7 @@
+1f you want to insert a new level do not use tab use .
+spacebar!!! .
+missionOne.oxw 1 .
+fightInOurBack.oxw 1 .
+pirateAttack.oxw 1 .
+iJohnVane_TriptoArea51.oxw 0 .
+............................................................
\ No newline at end of file
Modified: code/branches/storymodeHS14/src/orxonox/gametypes/Mission.cc
===================================================================
--- code/branches/storymodeHS14/src/orxonox/gametypes/Mission.cc 2014-12-04 16:16:20 UTC (rev 10156)
+++ code/branches/storymodeHS14/src/orxonox/gametypes/Mission.cc 2014-12-05 14:10:42 UTC (rev 10157)
@@ -35,8 +35,11 @@
#include "infos/PlayerInfo.h"
#include "network/Host.h"
#include "worldentities/pawns/Pawn.h"
+#include <iostream>
+#include <fstream>
+#include <string>
+#include <ios>
-
namespace orxonox
{
SetConsoleCommand("Mission", "endMission", &Mission::endMission);
@@ -77,16 +80,76 @@
void Mission::start()
{
+ std::fstream myfile;
+ myfile.open("/home/pmao/pmao-extra-0/orxonox/storymodeHS14/data/gui/scripts/campaign.txt");
+ std::string line;
+ std::string mission=this->getFilename();
+ int k=58-mission.length();
+ std::string helperstring = "";
+ if(myfile.is_open()){
+ while (k>1) {
+ helperstring=helperstring+" ";
+ k=k-1;
+ }
+ helperstring=helperstring+".";
+ while(getline (myfile,line)){
+ if(line==mission+" 0"+helperstring){
+ long pos = myfile.tellp();
+ myfile.seekp (pos-61);
+ myfile << mission+" 1"+helperstring;
+ }
+ }}
+ else{
+ this->end();
+ }
+ myfile.flush();
+ myfile.clear();
+ myfile.close();
Gametype::start();
this->setTeams();
this->gtinfo_->sendAnnounceMessage("Your mission has started!");
}
+ std::string GenerateHelperString(int number){
+ std::string helperstring = "";
+ while (number>1) {
+ helperstring=helperstring+" ";
+ number=number-1;
+ }
+ helperstring=helperstring+".";
+ return helperstring;
+ }
+
void Mission::end()
{
- if (this->missionAccomplished_ && !this->gtinfo_->hasEnded())
+
+ if (this->missionAccomplished_ && !this->gtinfo_->hasEnded()){
this->gtinfo_->sendAnnounceMessage("Mission accomplished!");
+ std::fstream myfile;
+ myfile.open("/home/pmao/pmao-extra-0/orxonox/storymodeHS14/data/gui/scripts/campaign.txt");
+ std::string line;
+ std::string mission=this->getFilename();
+ int k=58-mission.length();
+ std::string helperstring = "";
+ if(myfile.is_open()){
+ while (k>1) {
+ helperstring=helperstring+" ";
+ k=k-1;
+ }
+ helperstring=helperstring+".";
+ while(getline (myfile,line)){
+ if(line==mission+" 0"+helperstring){
+ long pos = myfile.tellp();
+ myfile.seekp (pos-61);
+ myfile << mission+" 1"+helperstring;
+ }
+ }}
+ myfile.flush();
+ myfile.clear();
+ myfile.close();
+ }
+
else if (!this->gtinfo_->hasEnded())
this->gtinfo_->sendAnnounceMessage("Mission failed!");
Gametype::end();
@@ -105,11 +168,37 @@
{
for (ObjectList<Mission>::iterator it = ObjectList<Mission>::begin(); it != ObjectList<Mission>::end(); ++it)
{//TODO: make sure that only the desired mission is ended !! This is a dirty HACK, that would end ALL missions!
- it->setMissionAccomplished(accomplished);
+ if(accomplished){
+ std::fstream myfile;
+ myfile.open("/home/pmao/pmao-extra-0/orxonox/storymodeHS14/data/gui/scripts/campaign.txt");
+ std::string line;
+ std::string mission=it->getFilename();
+ int k=58-mission.length();
+ std::string helperstring = "";
+ if(myfile.is_open()){
+ while (k>1) {
+ helperstring=helperstring+" ";
+ k=k-1;
+ }
+ helperstring=helperstring+".";
+ while(getline (myfile,line)){
+ if(line==mission+" 0"+helperstring){
+ long pos = myfile.tellp();
+ myfile.seekp (pos-61);
+ myfile << mission+" 1"+helperstring;
+ }
+ }
+ }
+ myfile.flush();
+ myfile.clear();
+ myfile.close();
+ }
+ it->setMissionAccomplished(accomplished);
it->end();
+
}
}
-
+
void Mission::setLivesWrapper(unsigned int amount)
{
for (ObjectList<Mission>::iterator it = ObjectList<Mission>::begin(); it != ObjectList<Mission>::end(); ++it)
More information about the Orxonox-commit
mailing list