Commits

Friedrich Kastner-Masilko committed d09c395

Pages: added door control page

  • Participants
  • Parent commits 6c39d7d

Comments (0)

Files changed (4)

Orbitersdk/samples/AscensionUltra/AscensionTower.vcproj

 				>
 			</File>
 			<File
+				RelativePath=".\Pages\DoorPage.h"
+				>
+			</File>
+			<File
 				RelativePath=".\Pages\GroundPage.h"
 				>
 			</File>

Orbitersdk/samples/AscensionUltra/Pages/AscensionTowerData.cpp

 #include "PersonHangarPage.h"
 #include "PersonRoomPage.h"
 #include "PaXferPage.h"
+#include "DoorPage.h"
 #include "TemplatePage.h"
 #pragma warning(disable : 4482)
 
 	pages[LaunchPrepare]=new TemplatePage(this);
 	pages[Bearing]=new TemplatePage(this);
 	pages[Launch]=new TemplatePage(this);
-	pages[DoorControl]=new TemplatePage(this);
+	pages[DoorControl]=new DoorPage(this);
 	pages[CraneControl]=new TemplatePage(this);
 	pages[PersonControl]=new TemplatePage(this);
 	pages[CraneList]=new TemplatePage(this);

Orbitersdk/samples/AscensionUltra/Pages/DoorListPage.h

 	AscensionTowerPageInstance Select(int index=-1)
 	{
 		AscensionTowerPage::Select(index);
-		data->GetPage(DoorControl)->SetDataRoot(((Hangar *)dataRoot)->GetDoor(selectedIndex));
+		Hangar *hangar = (Hangar *)dataRoot;
+		dataSet[0]=hangar->GetName();
+		dataSet[1]=hangar->GetDoor(selectedIndex);
+		data->GetPage(DoorControl)->SetDataRoot(dataSet);
 		return DoorControl;
 	}
 
+private:
+	void* dataSet[2];
+
 };

Orbitersdk/samples/AscensionUltra/Pages/DoorPage.h

+#pragma once
+#include "AscensionTowerPage.h"
+#pragma warning(disable : 4482)
+
+class DoorPage: public AscensionTowerPage
+{
+
+public:
+
+	DoorPage(AscensionTowerData *data):AscensionTowerPage(data){}
+
+protected:
+
+	char *LabelRenderer (int bt)
+	{
+		switch (bt)
+		{
+			case 6: return "HOM";
+			case 7: return "BCK";
+			case 8: return "RES";
+			default: return AscensionTowerPage::LabelRenderer(bt);
+		}
+	}
+
+	int MenuRenderer (MFDBUTTONMENU *mnu)
+	{	
+		static MFDBUTTONMENU menu[3] = 
+		{
+			{"Main menu", NULL, 'H'},
+			{"Go back", NULL, 'B'},
+			{"Reset to default", "values", 'R'}
+		};
+		
+		mnu[0].line1="Select command";
+		for(int i=0;i<3;i++) mnu[6+i]=menu[i];	
+		return AscensionTowerPage::MenuRenderer(mnu);
+	}
+
+	AscensionTowerPageInstance KeyHandler(DWORD key)
+	{	
+		switch(key)
+		{	
+		case OAPI_KEY_H:
+			return MainMenu;
+		case OAPI_KEY_B:
+			return DoorSelection;
+		default:
+			return AscensionTowerPage::KeyHandler(key);
+		}
+	}
+
+	char *GetTitle(){return GetNameSafeTitle("Ground");}
+
+	char *GetSubtitle()
+	{
+		static char subtitle[57];
+		sprintf(subtitle, "%s -> %s",
+			(char *)((void **)dataRoot)[0],
+			((Door *)((void **)dataRoot)[1])->GetName());
+		return subtitle;
+	}
+
+	int GetListSize(){return 3;}
+
+	AscensionTowerListPair GetListItem(int index)
+	{
+		static AscensionTowerListPair doorMenu[3]={{0," Open"},{1," Close"},{2," Stop"}};	
+		return doorMenu[index];
+	}
+
+	AscensionTowerPageInstance Select(int index=-1)
+	{
+		AscensionTowerPage::Select(index);
+		Door *door=(Door *)((void **)dataRoot)[1];
+		switch(selectedIndex)
+		{
+		case 0: door->Open(); break;
+		case 1: door->Close(); break;
+		case 2: door->Stop(); break;
+		}
+		return NoChange;
+	}
+
+	void MFDRenderer()
+	{
+		AscensionTowerPage::MFDRenderer();
+		mfd->SetWriteStyle(0,2);
+		Door* door=(Door *)((void **)dataRoot)[1];
+		if (door->GetPosition()<=0) mfd->Write("Closed", 15);
+		else if (door->GetPosition()>=1) mfd->Write("Open", 15);
+		else mfd->Write("Moving", 15);
+	}
+
+};