using System;
using System.Collections;
using System.Xml;
using RealmForge.Scripting;
using RealmForge;
using RealmForge.UI;
using RealmForge.UI.Definitions;
using RealmForge.UI.Forms;
using System.Windows.Forms;
using RealmForge.UI.Forms.IDE.Docking;
using System.Drawing;
using ContentRealmForge.UI.Forms.IDE.Docking.Content;
using System.IO;
using System.ComponentModel;
namespace RSL.UI{
/// <summary>
/// The RSL.UI namespace contains scripts relating to GUI Toolkits such as WinForms for window creation and manipulation.
/// </summary>
internal class NamespaceDoc
{
}
#region Script Classes
[Description("Creates a window creation script for the owner IWindowManager that creates the default Launcher formand registers it.")]
public class CreateLauncher : IScript
{
#region Methods
public void Execute(object owner, object args)
{
try
{
string windowID = (string)args;
Form f = new Launcher();
f.Load += new EventHandler(BringToFront);
((IWindowManager)owner).Register(windowID,f);
}
catch(Exception e)
{
Log.Write(e);
}
}
#endregion
private void BringToFront(object sender, EventArgs e)
{
((Form)sender).BringToFront();
}
}
[Description("Creates and shows a form which acts as a black waiting screen showing RF.Config.GameLoadingTitleWithTroubleshootInformation as its text that can be closed with HideLoadingScreen().")]
public class ShowLoadingScreen : IScript {
#region Fields and Properties
protected Form loadingScreen = null;
protected Label waitLabel = null;
#endregion
#region Public Methods
public void Execute(object owner, object args)
{
Show();
}
public void Show() {
Form f = new Form();
f.Text = RF.Config.RenderWindowTitle;
f.TopMost = true;//prevents render window loading from being seen, but is impossible to debug
f.BackColor = Color.Black;
f.WindowState = FormWindowState.Maximized;
f.FormBorderStyle = FormBorderStyle.None;
f.StartPosition = FormStartPosition.CenterScreen;
f.Controls.Add(CreateWaitLabel());
loadingScreen = f;
loadingScreen.Show();
}
public Label CreateWaitLabel() {
waitLabel = new Label();
waitLabel.TextAlign = ContentAlignment.MiddleCenter;
waitLabel.ForeColor = Color.White;
waitLabel.BackColor = Color.Black;
waitLabel.Text = RF.Config.GameLoadingTitleWithTroubleshootInformation;
waitLabel.Font = new Font(StandardFonts.Arial, 24, GraphicsUnit.Point);
waitLabel.Dock = DockStyle.Fill;
return waitLabel;
}
public void HideLoadingScreen() {
waitLabel.Hide(); //hide until closes
loadingScreen.Close(); //close and clean up
}
#endregion
}
[Description("Performs the appropriate actions depending on the Text propety of the owner parameter representing the Control which was clicked.")]
public class HandleLauncherButtonClick : IScript {
#region Fields and Properties
protected bool alreadyStarted = false;
#endregion
#region Public Methods
public void ShowRenderWindow()
{
RF.Windows.Hide("Launcher");
}
public void Execute(object owner, object args) {
try{
Control button = (Control)owner;
string windowID = (string)button.Tag;
switch(windowID) {
case "New":
if(alreadyStarted)
return; //prevent from erroring when new is pressed 2x in a row
alreadyStarted = true;
ShowLoadingScreen loadingScreenController = new ShowLoadingScreen();
loadingScreenController.Show();
//General SwitchTo would be used to change to the RenderWindow from the Launcher, but Axiom automatically
//shows its own window on startup... this also means that we have to wait to customize it until Axiom startup has finished
//which leaves an ugly Axiom windows temporarily and also requires the AxiomIcon.ico to be present
RF.Engine.Initialized.AddHandlers(new SimpleMethod(loadingScreenController.HideLoadingScreen),new SimpleMethod(ShowRenderWindow));
RF.App.StartRendering();
break;
case "Load":
//RF.Windows.Hide("Launcher");
RF.Windows.Show("LoadScreen");
break;
case "Multiplayer":
//RF.Windows.Hide("Launcher");
RF.Windows.Show("PlayerLobby");
break;
case "Options":
//RF.Windows.Hide("Launcher");
RF.Windows.ShowDialog("OptionsDialog");
break;
case "Credits":
//RF.Windows.Hide("Launcher");
RF.Windows.ShowDialog("CreditsDialog");
break;
case "Readme":
RealmForge.Utility.RunFile(StandardResources.ReadmeFile);
break;
case "Exit":
RF.App.Shutdown();
break;
}
} catch(Exception e) {
Log.Write(e);
Errors.RealmForge("Launcher Button Click failed to handle");
}
}
#endregion
}
#endregion
}
|