static void Main(string[] args) { ThomasEngine.Debug.OnDebugMessage += Debug_OnDebugMessage; if (args.Length == 1) { run_time = UInt32.Parse(args[0]); } else { run_time = 0; } ThomasWrapper.Start(false); float startTime = Time.ElapsedTime; Win32Window window = new Win32Window(); window.create(System.AppDomain.CurrentDomain.FriendlyName, 800, 600); Application.currentProject = Project.LoadProject("..\\Data\\project.thomas"); ThomasWrapper.IssuePlay(); ThomasEngine.Debug.Log("Game loaded. It took " + (Time.ElapsedTime - startTime) + " ms"); window.loop(); ThomasEngine.Debug.Log("Shutting down"); ThomasWrapper.Exit(); }
private void translateButton_Click(object sender, RoutedEventArgs e) { scaleButton.IsChecked = false; rotateButton.IsChecked = false; translateButton.IsChecked = true; ThomasWrapper.SetEditorGizmoManipulatorOperation(ThomasWrapper.ManipulatorOperation.TRANSLATE); }
internal void loop() { MSG msg; if (ThomasStandalone.Program.run_time == 0) { while (GetMessage(out msg, IntPtr.Zero, 0, 0) != 0) { TranslateMessage(ref msg); DispatchMessage(ref msg); } } else { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); while (GetMessage(out msg, IntPtr.Zero, 0, 0) != 0 && stopwatch.ElapsedMilliseconds < ThomasStandalone.Program.run_time) { TranslateMessage(ref msg); DispatchMessage(ref msg); } } ThomasWrapper.eventHandler(windowHandle, msg.message, msg.wParam, msg.lParam); }
private void SelectedGameObjectChanged(object sender, RoutedPropertyChangedEventArgs <object> e) { if (!wasUnselected) { AssetBrowser.instance.UnselectItem(); } wasUnselected = false; ItemContainerGenerator gen = hierarchy.ItemContainerGenerator; if (hierarchy.SelectedItem != null) { TreeViewItem item = hierarchy.SelectedItem as TreeViewItem; if (item != null) { Inspector.instance.SelectedObject = (GameObject)item.DataContext; if (!ThomasWrapper.SelectedGameObjects.Contains((GameObject)item.DataContext)) { ThomasWrapper.SelectGameObject((GameObject)item.DataContext); } } } else { Inspector.instance.SelectedObject = null; } }
public override void Update() { MainMenu.color = Unselected; SwitchTeam.color = Unselected; OptionsMenu.color = Unselected; BackToGame.color = Unselected; ExitGame.color = Unselected; if (MainMenu.Hovered()) { MainMenu.color = Selected; } else if (SwitchTeam.Hovered() && _CanSwitchTeam) { SwitchTeam.color = Selected; } else if (OptionsMenu.Hovered()) { OptionsMenu.color = Selected; } else if (BackToGame.Hovered()) { BackToGame.color = Selected; } else if (ExitGame.Hovered()) { ExitGame.color = Selected; } if (MainMenu.Clicked()) { if (ThomasWrapper.IsPlaying()) { Input.SetMouseMode(Input.MouseMode.POSITION_ABSOLUTE); CameraMaster.instance.SetState(CAM_STATE.LOADING_SCREEN); ThomasWrapper.IssueRestart(); } } else if (SwitchTeam.Clicked() && _CanSwitchTeam) { CameraMaster.instance.Canvas.isRendering = true; gameObject.GetComponent <ChadCam>().enabled = false; CameraMaster.instance.SetState(CAM_STATE.SELECT_TEAM); } else if (OptionsMenu.Clicked()) { GUIOptionsMenu.instance.ActivatedfromExitmenu = true; CameraMaster.instance.SetState(CAM_STATE.OPTIONS_MENU); } else if (BackToGame.Clicked()) { CameraMaster.instance.SetState(CAM_STATE.GAME); Input.SetMouseMode(Input.MouseMode.POSITION_RELATIVE); } else if (ExitGame.Clicked()) { ThomasWrapper.IssueShutdown(); } }
public void Unselect() { if (hierarchy.SelectedItem != null) { wasUnselected = true; ThomasWrapper.UnselectGameObjects(); } }
internal bool create(string name, int width, int height) { windowHandle = ThomasWrapper.CreateThomasWindow(name, width, height); ShowWindow(windowHandle, 1); UpdateWindow(windowHandle); return(true); }
private void DoUpdates(object sender, EventArgs e) { RenderingEventArgs args = (RenderingEventArgs)e; if (this.lastRender != args.RenderingTime) { ThomasWrapper.Update(); editorWindow.Title = ThomasWrapper.FrameRate.ToString(); lastRender = args.RenderingTime; transformGizmo.UpdateTransformGizmo(); } }
private void PlayPauseButton_Click(object sender, ExecutedRoutedEventArgs e) { if (ThomasWrapper.IsPlaying()) { ThomasWrapper.Stop(); } else { ThomasWrapper.Play(); } playPauseButton.DataContext = ThomasWrapper.IsPlaying(); }
public void UpdateTransformGizmo() { switch (ThomasWrapper.GetEditorGizmoManipulatorOperation()) { case ThomasWrapper.ManipulatorOperation.TRANSLATE: translateButton_Click(null, null); break; case ThomasWrapper.ManipulatorOperation.ROTATE: rotateButton_Click(null, null); break; case ThomasWrapper.ManipulatorOperation.SCALE: scaleButton_Click(null, null); break; } }
protected override HandleRef BuildWindowCore(HandleRef parent) { var callback = Marshal.GetFunctionPointerForDelegate(procedure = WndProc); var width = Convert.ToInt32(ActualWidth); var height = Convert.ToInt32(ActualHeight); var cursor = LoadCursor(IntPtr.Zero, 32512); var menu = string.Empty; var background = new IntPtr(1); var zero = IntPtr.Zero; var caption = string.Empty; var style = 3u; var extra = 0; var extended = 0u; var window = 0x50000000u; var point = 0; var name = "Win32"; var wnd = new WindowClass { Style = style, Callback = callback, ClassExtra = extra, WindowExtra = extra, Instance = zero, Icon = zero, Cursor = cursor, Background = background, Menu = menu, Class = name }; RegisterClass(ref wnd); Handle = CreateWindowEx(extended, name, caption, window, point, point, width, height, parent.Handle, zero, zero, zero); ThomasWrapper.CreateThomasWindow(Handle, IsEditor); return(new HandleRef(this, Handle)); }
public override void Update() { foreach (var text in Textdatalist) { text.color = Color.FloralWhite; } if (Textdatalist[0].Hovered()) { Textdatalist[0].color = Color.IndianRed; Textdatalist[2].color = Color.IndianRed; } if (Textdatalist[1].Hovered()) { Textdatalist[1].color = Color.IndianRed; } if (Textdatalist[0].Clicked())//Play again { } if (Textdatalist[1].Clicked())//Main menu { if (ThomasWrapper.IsPlaying()) { Input.SetMouseMode(Input.MouseMode.POSITION_ABSOLUTE); CameraMaster.instance.SetState(CAM_STATE.LOADING_SCREEN); ThomasWrapper.IssueRestart(); } //foreach (Text Textdata in Textdatalist) // Textdata.scale = Vector2.Zero; } Textdatalist[2].position = Textdatalist[0].position + new Vector2(Textdatalist[0].size.x / 2 + Textdatalist[2].size.x / 2, 0); if (TimerRoutine == null) { TimerRoutine = CountDown(); StartCoroutine(CountDown()); } }
protected override IntPtr WndProc(IntPtr handle, int message, IntPtr wparam, IntPtr lparam, ref bool handled) { try { if (message == WM_PAINT) { Paint paint; BeginPaint(handle, out paint); EndPaint(handle, ref paint); handled = true; } else { } ThomasWrapper.eventHandler(handle, message, wparam, lparam); } catch (Exception e) { MessageBox.Show(e.Message); } return(base.WndProc(handle, message, wparam, lparam, ref handled)); }
public override void Update() { if (Canvas.isRendering) { Play.color = Unselected; HostGame.color = Unselected; Options.color = Unselected; Credits.color = Unselected; Exit.color = Unselected; RandomHat.color = Unselected; if (Play.Hovered()) { Play.color = Selected; } else if (HostGame.Hovered()) { HostGame.color = Selected; } else if (Options.Hovered()) { Options.color = Selected; } else if (Credits.Hovered()) { Credits.color = Selected; } else if (Exit.Hovered()) { Exit.color = Selected; } else if (RandomHat.Hovered()) { RandomHat.color = Selected; } if (Input.GetMouseButtonDown(Input.MouseButtons.LEFT)) { if (ChadArea.Hovered()) { Input.SetMouseMode(Input.MouseMode.POSITION_RELATIVE); _RotateChad = true; } } if (MyNameSticker.Clicked()) { TakeName = true; if (Blink == null) { Blink = CaretBlink(); StartCoroutine(Blink); } if (ClearName) { PlayerName.text = ""; ClearName = false; } } else if (Input.GetMouseButtonUp(Input.MouseButtons.LEFT)) { Input.SetMouseMode(Input.MouseMode.POSITION_ABSOLUTE); _RotateChad = false; TakeName = false; if (Blink != null) { StopCoroutine(Blink); Blink = null; } Caret.text = ""; } #region Clicked if (Play.Clicked() && PlayerName.text != "") { CameraMaster.instance.SetState(CAM_STATE.JOIN_HOST); TakeName = false; UserSettings.AddOrUpdateAppSetting("Hat", CameraMaster.instance.SelectedHat.ToString()); UserSettings.AddOrUpdateAppSetting("PlayerName", PlayerName.text); } else if (HostGame.Clicked()) { CameraMaster.instance.SetState(CAM_STATE.HOST_MENU); TakeName = false; UserSettings.AddOrUpdateAppSetting("Hat", CameraMaster.instance.SelectedHat.ToString()); UserSettings.AddOrUpdateAppSetting("PlayerName", PlayerName.text); } else if (Exit.Clicked()) { ThomasWrapper.IssueShutdown(); } else if (SelectHatRight.Clicked()) { CameraMaster.instance.SelectedHat += 1; AnnouncerSoundManager.Instance.Announce(ANNOUNCEMENT_TYPE.HAT); } else if (SelectHatLeft.Clicked()) { CameraMaster.instance.SelectedHat -= 1; AnnouncerSoundManager.Instance.Announce(ANNOUNCEMENT_TYPE.HAT); } else if (RandomHat.Clicked()) { CameraMaster.instance.SelectedHat = (int)(Random.Range(0.0f, 1.0f) * (HatManager.Instance.Hats.Count - 2)) + 1; AnnouncerSoundManager.Instance.Announce(ANNOUNCEMENT_TYPE.HAT); } else if (Options.Clicked()) { CameraMaster.instance.SetState(CAM_STATE.OPTIONS_MENU); } #endregion if (TakeName) { string playerString = PlayerName.text; GUIInput.AppendString(ref playerString, 9); PlayerName.text = playerString; } RotateChad(); Caret.position = PlayerName.position + new Vector2(PlayerName.size.x / 2 - 0.005f, CaretOffset + PlayerName.size.x * NameRotation); } }
protected override void OnStartup(StartupEventArgs e) { ThomasWrapper.Start(); }
protected override void OnExit(ExitEventArgs e) { ThomasWrapper.Exit(); }
private void transformModeButton_Click(object sender, RoutedEventArgs e) { ThomasWrapper.ToggleEditorGizmoManipulatorMode(); }
public override void Update() { Chad1Mat?.SetColor("color", MatchSystem.instance.Teams[TEAM_TYPE.TEAM_1].Color); Chad2Mat?.SetColor("color", MatchSystem.instance.Teams[TEAM_TYPE.TEAM_2].Color); if (Canvas.isRendering) { transform.position = SelectTeamCamPos; Team1Text.text = MatchSystem.instance.Teams[TEAM_TYPE.TEAM_1].Name; Team2Text.text = MatchSystem.instance.Teams[TEAM_TYPE.TEAM_2].Name; ShowPlayers(); if (Team1Image.Clicked()) { MatchSystem.instance.JoinTeam(TEAM_TYPE.TEAM_1); MatchSystem.instance.LocalChad.NetPlayer.Ready(false); ReadyUp.rendering = true; if (MatchSystem.instance.MatchStarted) { Input.SetMouseMode(Input.MouseMode.POSITION_RELATIVE); CameraMaster.instance.SetState(CAM_STATE.GAME); CameraMaster.instance.Canvas.isRendering = false; gameObject.GetComponent <ChadCam>().enabled = true; MatchSystem.instance.LocalChad.NetPlayer.HatIndex = CameraMaster.instance.SelectedHat; } } else if (Team2Image.Clicked()) { MatchSystem.instance.JoinTeam(TEAM_TYPE.TEAM_2); MatchSystem.instance.LocalChad.NetPlayer.Ready(false); ReadyUp.rendering = true; if (MatchSystem.instance.MatchStarted) { Input.SetMouseMode(Input.MouseMode.POSITION_RELATIVE); CameraMaster.instance.SetState(CAM_STATE.GAME); CameraMaster.instance.Canvas.isRendering = false; gameObject.GetComponent <ChadCam>().enabled = true; MatchSystem.instance.LocalChad.NetPlayer.HatIndex = CameraMaster.instance.SelectedHat; } } else if (SpectatorImage.Clicked() || SpectatorText.Clicked()) { MatchSystem.instance.JoinTeam(TEAM_TYPE.TEAM_SPECTATOR); MatchSystem.instance.LocalChad.NetPlayer.Ready(true); ReadyUp.rendering = false; if (MatchSystem.instance.MatchStarted) { Input.SetMouseMode(Input.MouseMode.POSITION_RELATIVE); CameraMaster.instance.SetState(CAM_STATE.GAME); CameraMaster.instance.Canvas.isRendering = false; gameObject.GetComponent <SpectatorCam>().enabled = true; gameObject.GetComponent <SpectatorCam>().EnableSpeCam(); } } else if (ReadyUp.Clicked()) { if (MatchSystem.instance.LocalChad.NetPlayer.GetReady()) { MatchSystem.instance.LocalChad.NetPlayer.Ready(false); } else { MatchSystem.instance.LocalChad.NetPlayer.Ready(true); } } else if (ExitText.Clicked()) { MatchSystem.instance.Disconnect(); ThomasWrapper.IssueRestart(); } else if ((StartGame.Clicked() || (MatchSystem.instance.MatchLength == MatchSystem.instance.MatchTimeLeft && MatchSystem.instance.MatchStarted)) && Canvas.isRendering) { Input.SetMouseMode(Input.MouseMode.POSITION_RELATIVE); CameraMaster.instance.SetState(CAM_STATE.GAME); CameraMaster.instance.Canvas.isRendering = false; MatchSystem.instance.OnMatchStart(); MatchSystem.instance.LocalChad.NetPlayer.HatIndex = CameraMaster.instance.SelectedHat; } Team1Text.color = Unselected; Team2Text.color = Unselected; SpectatorText.color = Unselected; ReadyUp.color = Unselected; StartGame.color = Unselected; ExitText.color = Unselected; if (Team1Image.Hovered()) { Team1Text.color = Selected; if (RunningAnim != null) { if (ChadRSC1.animation != RunningAnim) { ChadRSC1.animation = RunningAnim; ChadRSC2.animation = IdleAnim; } } } else if (Team2Image.Hovered()) { Team2Text.color = Selected; if (RunningAnim != null) { if (ChadRSC2.animation != RunningAnim) { ChadRSC1.animation = IdleAnim; ChadRSC2.animation = RunningAnim; } } } else if (SpectatorImage.Hovered() || SpectatorText.Hovered()) { SpectatorText.color = Selected; } else if (ReadyUp.Hovered() && ReadyUp.rendering) { ReadyUp.color = Selected; } else if (StartGame.Hovered() && CheckReadyPlayers()) { StartGame.color = Selected; } else if (ExitText.Hovered()) { ExitText.color = Selected; } else { IdleChads(); } if (CheckReadyPlayers()) { StartGame.rendering = true; } else { StartGame.rendering = false; } if (ReadyUp.rendering) { if (MatchSystem.instance.LocalChad.NetPlayer.GetReady()) { ReadyUp.text = "Unready"; } else { ReadyUp.text = "Ready"; } } if (MatchSystem.instance.MatchStarted) { ReadyUp.rendering = false; StartGame.rendering = false; } } }
private void AddEmptyGameObject(object sender, RoutedEventArgs e) { var x = new GameObject("gameObject"); ThomasWrapper.SelectGameObject(x); }
private void AddNewCapsulePrimitive(object sender, RoutedEventArgs e) { var x = GameObject.CreatePrimitive(PrimitiveType.Capsule); ThomasWrapper.SelectGameObject(x); }