public WaitState(DwarfGame game, string name, GameStateManager stateManager, WaitThreadRoutine routine) : base(game, name, stateManager) { WaitThread = new Thread(() => { System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; System.Threading.Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture; runRoutine(routine); }) { IsBackground = true }; OnFinished = (Boolean, Exception) => { }; Done = false; GuiRoot = new Gui.Root(DwarfGame.GuiSkin) { MousePointer = new MousePointer("mouse", 15.0f, 16, 17, 18, 19, 20, 21, 22, 23) }; GuiRoot.RootItem.AddChild(new Widget() { Text = name, Font = "font18-outline", AutoLayout = AutoLayout.DockFill, TextColor = Color.White.ToVector4(), TextHorizontalAlign = HorizontalAlign.Center, TextVerticalAlign = VerticalAlign.Center, Rect = GuiRoot.RenderData.VirtualScreen }); }
public WaitState(DwarfGame game, string name, GameStateManager stateManager, WaitThreadRoutine routine, DwarfGUI gui) : base(game, name, stateManager) { WaitThread = new Thread(() => runRoutine(routine)); GUI = gui; OnFinished = (Boolean, Exception) => { }; Done = false; }
protected void runRoutine(WaitThreadRoutine routine) { try { success = routine(); } catch (WaitStateException e) // allows any exceptions we didn't throw on purpose to be thrown properly { this.exception = e; } }