void SetDefaults() { string fname = WASD_CFG_FILE + ".default"; if (System.IO.File.Exists(fname)) { ConfigNode file = ConfigNode.Load(fname); var root = file.GetNode(WASD_NODENAME); newconfig = parseConfigNode(root); cfgWinData = false; defaultsLoaded = true; } //newconfig = configFile; }
private void Window(int id) { if (cfgWinData == false) { cfgWinData = true; if (!defaultsLoaded) { newconfig = WasdEditorCameraBehaviour.config; } defaultsLoaded = false; strkeyForward = newconfig.keyForward.ToString(); strkeyBack = newconfig.keyBack.ToString(); strkeyRight = newconfig.keyRight.ToString(); strkeyLeft = newconfig.keyLeft.ToString(); strkeyUp = newconfig.keyUp.ToString(); strkeyDown = newconfig.keyDown.ToString(); strkeyRun = newconfig.keyRun.ToString(); strkeySneak = newconfig.keySneak.ToString(); strkeySwitchMode = newconfig.keySwitchMode.ToString(); #if true cbkeyForward.SetSelectedItemIndex(strkeyForward, comboBoxList); cbkeyBack.SetSelectedItemIndex(strkeyBack, comboBoxList); cbkeyRight.SetSelectedItemIndex(strkeyRight, comboBoxList); cbkeyLeft.SetSelectedItemIndex(strkeyLeft, comboBoxList); cbkeyUp.SetSelectedItemIndex(strkeyUp, comboBoxList); cbkeyDown.SetSelectedItemIndex(strkeyDown, comboBoxList); cbkeyRun.SetSelectedItemIndex(strkeyRun, comboBoxList); cbkeySneak.SetSelectedItemIndex(strkeySneak, comboBoxList); cbkeySwitchMode.SetSelectedItemIndex(strkeySwitchMode, comboBoxList); #endif strsensitivity = newconfig.sensitivity.ToString(); stracceleration = newconfig.acceleration.ToString(); strmouseWheelAcceleration = newconfig.mouseWheelAcceleration.ToString(); strfriction = newconfig.friction.ToString(); strrunMultiplier = newconfig.runMultiplier.ToString(); strsneakMultiplier = newconfig.sneakMultiplier.ToString(); strVabInitPosX = newconfig.vab.initialPosition.x.ToString(); strVabInitPosY = newconfig.vab.initialPosition.y.ToString(); strVabInitPosZ = newconfig.vab.initialPosition.z.ToString(); strVabInitPitch = newconfig.vab.initialPitch.ToString(); strVabInitYaw = newconfig.vab.initialYaw.ToString(); strVabBoundsMinX = newconfig.vab.bounds.min.x.ToString(); strVabBoundsMinY = newconfig.vab.bounds.min.y.ToString(); strVabBoundsMinZ = newconfig.vab.bounds.min.z.ToString(); strVabBoundsMaxX = newconfig.vab.bounds.max.x.ToString(); strVabBoundsMaxY = newconfig.vab.bounds.max.y.ToString(); strVabBoundsMaxZ = newconfig.vab.bounds.max.z.ToString(); strSphInitPosX = newconfig.sph.initialPosition.x.ToString(); strSphInitPosY = newconfig.sph.initialPosition.y.ToString(); strSphInitPosZ = newconfig.sph.initialPosition.z.ToString(); strSphInitPitch = newconfig.sph.initialPitch.ToString(); strSphInitYaw = newconfig.sph.initialYaw.ToString(); strSphBoundsMinX = newconfig.sph.bounds.min.x.ToString(); strSphBoundsMinY = newconfig.sph.bounds.min.y.ToString(); strSphBoundsMinZ = newconfig.sph.bounds.min.z.ToString(); strSphBoundsMaxX = newconfig.sph.bounds.max.x.ToString(); strSphBoundsMaxY = newconfig.sph.bounds.max.y.ToString(); strSphBoundsMaxZ = newconfig.sph.bounds.max.z.ToString(); } SetVisible(true); GUI.enabled = true; GUILayout.BeginHorizontal(); GUILayout.EndHorizontal(); GUILayout.BeginArea(new Rect(10, 50, 375, 500)); GUILayout.BeginVertical(); DrawTitle("Keys"); GUILayout.BeginHorizontal(); GUILayout.Label("Key forward: "); #if true // GUILayout.BeginArea (new Rect (10, 20, 300, 500)); // strkeyForward = comboBoxList[cbkeyForward.List (new Rect (125, 5, 150, 20), strkeyForward, comboBoxList, listStyle)].text; // GUILayout.EndArea (); #else GUILayout.FlexibleSpace(); strkeyForward = GUILayout.TextField(strkeyForward, GUILayout.MinWidth(60.0F), GUILayout.MaxWidth(60.0F)); #endif GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Key back: "); #if true // GUILayout.BeginArea (new Rect (10, 45, 300, 500)); // strkeyBack = comboBoxList[cbkeyBack.List (new Rect (125, 5, 150, 20), strkeyBack, comboBoxList, listStyle)].text; // GUILayout.EndArea (); #else GUILayout.FlexibleSpace(); strkeyBack = GUILayout.TextField(strkeyBack, GUILayout.MinWidth(60.0F), GUILayout.MaxWidth(60.0F)); #endif GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Key right: "); #if true // GUILayout.BeginArea (new Rect (10, 70, 300, 500)); // strkeyRight = comboBoxList[cbkeyRight.List (new Rect (125, 5, 150, 20), strkeyRight, comboBoxList, listStyle)].text; // GUILayout.EndArea (); #else GUILayout.FlexibleSpace(); strkeyRight = GUILayout.TextField(strkeyRight, GUILayout.MinWidth(60.0F), GUILayout.MaxWidth(60.0F)); #endif GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Key left: "); #if true // GUILayout.BeginArea (new Rect (10, 95, 300, 500)); // strkeyLeft = comboBoxList[cbkeyLeft.List (new Rect (125, 5, 150, 20), strkeyLeft, comboBoxList, listStyle)].text; // GUILayout.EndArea (); #else GUILayout.FlexibleSpace(); strkeyLeft = GUILayout.TextField(strkeyLeft, GUILayout.MinWidth(60.0F), GUILayout.MaxWidth(60.0F)); #endif GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Key up: "); #if true // GUILayout.BeginArea (new Rect (10, 120, 300, 500)); // strkeyUp = comboBoxList[cbkeyUp.List (new Rect (125, 5, 150, 20), strkeyUp, comboBoxList, listStyle)].text; // GUILayout.EndArea (); #else GUILayout.FlexibleSpace(); strkeyUp = GUILayout.TextField(strkeyUp, GUILayout.MinWidth(60.0F), GUILayout.MaxWidth(60.0F)); #endif GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Key down: "); #if true // GUILayout.BeginArea (new Rect (10, 145, 300, 500)); // strkeyDown = comboBoxList[cbkeyDown.List (new Rect (125, 5, 150, 20), strkeyDown, comboBoxList, listStyle)].text; // GUILayout.EndArea (); #else GUILayout.FlexibleSpace(); strkeyDown = GUILayout.TextField(strkeyDown, GUILayout.MinWidth(60.0F), GUILayout.MaxWidth(60.0F)); #endif GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Key run: "); #if true // GUILayout.BeginArea (new Rect (10, 170, 300, 500)); // strkeyRun = comboBoxList[cbkeyRun.List (new Rect (125, 5, 150, 20), strkeyRun, comboBoxList, listStyle)].text; // GUILayout.EndArea (); #else GUILayout.FlexibleSpace(); strkeyRun = GUILayout.TextField(strkeyRun, GUILayout.MinWidth(60.0F), GUILayout.MaxWidth(60.0F)); #endif GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Key sneak: "); #if true // GUILayout.BeginArea (new Rect (10, 195, 300, 500)); // strkeySneak = comboBoxList[cbkeySneak.List (new Rect (125, 5, 150, 20), strkeySneak, comboBoxList, listStyle)].text; // GUILayout.EndArea (); #else GUILayout.FlexibleSpace(); strkeySneak = GUILayout.TextField(strkeySneak, GUILayout.MinWidth(60.0F), GUILayout.MaxWidth(60.0F)); #endif GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Key switch mode: "); #if true // GUILayout.BeginArea (new Rect (10, 220, 300, 500)); // strkeySwitchMode = comboBoxList[cbkeySwitchMode.List (new Rect (125, 5, 150, 20), strkeySwitchMode, comboBoxList, listStyle)].text; // GUILayout.EndArea (); #else GUILayout.FlexibleSpace(); strkeySwitchMode = GUILayout.TextField(strkeySwitchMode, GUILayout.MinWidth(60.0F), GUILayout.MaxWidth(60.0F)); #endif GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label(""); GUILayout.EndHorizontal(); DrawTitle("VAB", true); GUILayout.BeginHorizontal(); GUILayout.Label("Initial Position: "); GUILayout.FlexibleSpace(); strVabInitPosX = GUILayout.TextField(strVabInitPosX, GUILayout.MinWidth(60.0F), GUILayout.MaxWidth(60.0F)); strVabInitPosY = GUILayout.TextField(strVabInitPosY, GUILayout.MinWidth(60.0F), GUILayout.MaxWidth(60.0F)); strVabInitPosZ = GUILayout.TextField(strVabInitPosZ, GUILayout.MinWidth(60.0F), GUILayout.MaxWidth(60.0F)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Initial Pitch: "); GUILayout.FlexibleSpace(); strVabInitPitch = GUILayout.TextField(strVabInitPitch, GUILayout.MinWidth(60.0F), GUILayout.MaxWidth(60.0F)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Initial Yaw: "); GUILayout.FlexibleSpace(); strVabInitYaw = GUILayout.TextField(strVabInitYaw, GUILayout.MinWidth(60.0F), GUILayout.MaxWidth(60.0F)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Bounds min: "); GUILayout.FlexibleSpace(); // x, y, z strVabBoundsMinX = GUILayout.TextField(strVabBoundsMinX, GUILayout.MinWidth(60.0F), GUILayout.MaxWidth(60.0F)); strVabBoundsMinY = GUILayout.TextField(strVabBoundsMinY, GUILayout.MinWidth(60.0F), GUILayout.MaxWidth(60.0F)); strVabBoundsMinZ = GUILayout.TextField(strVabBoundsMinZ, GUILayout.MinWidth(60.0F), GUILayout.MaxWidth(60.0F)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Bounds max: "); GUILayout.FlexibleSpace(); // x, y, z strVabBoundsMaxX = GUILayout.TextField(strVabBoundsMaxX, GUILayout.MinWidth(60.0F), GUILayout.MaxWidth(60.0F)); strVabBoundsMaxY = GUILayout.TextField(strVabBoundsMaxY, GUILayout.MinWidth(60.0F), GUILayout.MaxWidth(60.0F)); strVabBoundsMaxZ = GUILayout.TextField(strVabBoundsMaxZ, GUILayout.MinWidth(60.0F), GUILayout.MaxWidth(60.0F)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label(""); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Defaults", GUILayout.Width(125.0f))) { SetDefaults(); } GUILayout.EndHorizontal(); /////////////////////////////////////////////// /// These have to be here so that when they are clicked on, they will overwrite the other controls in the column /// GUILayout.BeginArea(new Rect(10, 20, 300, 500)); strkeyForward = comboBoxList [cbkeyForward.List(new Rect(125, 5, 150, 20), strkeyForward, comboBoxList, listStyle)].text; GUILayout.EndArea(); GUILayout.BeginArea(new Rect(10, 45, 300, 500)); strkeyBack = comboBoxList [cbkeyBack.List(new Rect(125, 5, 150, 20), strkeyBack, comboBoxList, listStyle)].text; GUILayout.EndArea(); GUILayout.BeginArea(new Rect(10, 70, 300, 500)); strkeyRight = comboBoxList [cbkeyRight.List(new Rect(125, 5, 150, 20), strkeyRight, comboBoxList, listStyle)].text; GUILayout.EndArea(); GUILayout.BeginArea(new Rect(10, 95, 300, 500)); strkeyLeft = comboBoxList [cbkeyLeft.List(new Rect(125, 5, 150, 20), strkeyLeft, comboBoxList, listStyle)].text; GUILayout.EndArea(); GUILayout.BeginArea(new Rect(10, 120, 300, 500)); strkeyUp = comboBoxList [cbkeyUp.List(new Rect(125, 5, 150, 20), strkeyUp, comboBoxList, listStyle)].text; GUILayout.EndArea(); GUILayout.BeginArea(new Rect(10, 145, 300, 500)); strkeyDown = comboBoxList [cbkeyDown.List(new Rect(125, 5, 150, 20), strkeyDown, comboBoxList, listStyle)].text; GUILayout.EndArea(); GUILayout.BeginArea(new Rect(10, 170, 300, 500)); strkeyRun = comboBoxList [cbkeyRun.List(new Rect(125, 5, 150, 20), strkeyRun, comboBoxList, listStyle)].text; GUILayout.EndArea(); GUILayout.BeginArea(new Rect(10, 195, 300, 500)); strkeySneak = comboBoxList [cbkeySneak.List(new Rect(125, 5, 150, 20), strkeySneak, comboBoxList, listStyle)].text; GUILayout.EndArea(); GUILayout.BeginArea(new Rect(10, 220, 300, 500)); strkeySwitchMode = comboBoxList [cbkeySwitchMode.List(new Rect(125, 5, 150, 20), strkeySwitchMode, comboBoxList, listStyle)].text; GUILayout.EndArea(); GUILayout.EndVertical(); GUILayout.EndArea(); GUILayout.BeginArea(new Rect(400, 50, 300, 500)); GUILayout.BeginVertical(); DrawTitle("Misc"); GUILayout.BeginHorizontal(); GUILayout.Label("Exp Editor Ext. Compatibility: "); GUILayout.FlexibleSpace(); newconfig.enableExperimentalEditorExtensionsCompatibility = GUILayout.Toggle(newconfig.enableExperimentalEditorExtensionsCompatibility, ""); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Default Camera: "); GUILayout.FlexibleSpace(); newconfig.defaultCamera = GUILayout.Toggle(newconfig.defaultCamera, ""); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Mouse wheel active: "); GUILayout.FlexibleSpace(); newconfig.mouseWheelActive = GUILayout.Toggle(newconfig.mouseWheelActive, ""); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Enforce bounds: "); GUILayout.FlexibleSpace(); newconfig.enforceBounds = GUILayout.Toggle(newconfig.enforceBounds, ""); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Sensitivity: "); GUILayout.FlexibleSpace(); strsensitivity = GUILayout.TextField(strsensitivity, GUILayout.MinWidth(60.0F), GUILayout.MaxWidth(60.0F)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Acceleration: "); GUILayout.FlexibleSpace(); stracceleration = GUILayout.TextField(stracceleration, GUILayout.MinWidth(60.0F), GUILayout.MaxWidth(60.0F)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Mouse wheel acceleration: "); GUILayout.FlexibleSpace(); strmouseWheelAcceleration = GUILayout.TextField(strmouseWheelAcceleration, GUILayout.MinWidth(60.0F), GUILayout.MaxWidth(60.0F)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Friction: "); GUILayout.FlexibleSpace(); strfriction = GUILayout.TextField(strfriction, GUILayout.MinWidth(60.0F), GUILayout.MaxWidth(60.0F)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Run multiplier: "); GUILayout.FlexibleSpace(); strrunMultiplier = GUILayout.TextField(strrunMultiplier, GUILayout.MinWidth(60.0F), GUILayout.MaxWidth(60.0F)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Sneak multiplier: "); GUILayout.FlexibleSpace(); strsneakMultiplier = GUILayout.TextField(strsneakMultiplier, GUILayout.MinWidth(60.0F), GUILayout.MaxWidth(60.0F)); GUILayout.EndHorizontal(); //GUILayout.BeginHorizontal (); //GUILayout.Label (""); //GUILayout.EndHorizontal (); DrawTitle("SPH", true); GUILayout.BeginHorizontal(); GUILayout.Label("Initial Position: "); GUILayout.FlexibleSpace(); strSphInitPosX = GUILayout.TextField(strSphInitPosX, GUILayout.MinWidth(60.0F), GUILayout.MaxWidth(60.0F)); strSphInitPosY = GUILayout.TextField(strSphInitPosY, GUILayout.MinWidth(60.0F), GUILayout.MaxWidth(60.0F)); strSphInitPosZ = GUILayout.TextField(strSphInitPosZ, GUILayout.MinWidth(60.0F), GUILayout.MaxWidth(60.0F)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Initial Pitch: "); GUILayout.FlexibleSpace(); strSphInitPitch = GUILayout.TextField(strSphInitPitch, GUILayout.MinWidth(60.0F), GUILayout.MaxWidth(60.0F)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Initial Yaw: "); GUILayout.FlexibleSpace(); strSphInitYaw = GUILayout.TextField(strSphInitYaw, GUILayout.MinWidth(60.0F), GUILayout.MaxWidth(60.0F)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Bounds min: "); GUILayout.FlexibleSpace(); // x, y, z strSphBoundsMinX = GUILayout.TextField(strSphBoundsMinX, GUILayout.MinWidth(60.0F), GUILayout.MaxWidth(60.0F)); strSphBoundsMinY = GUILayout.TextField(strSphBoundsMinY, GUILayout.MinWidth(60.0F), GUILayout.MaxWidth(60.0F)); strSphBoundsMinZ = GUILayout.TextField(strSphBoundsMinZ, GUILayout.MinWidth(60.0F), GUILayout.MaxWidth(60.0F)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Bounds max: "); GUILayout.FlexibleSpace(); // x, y, z strSphBoundsMaxX = GUILayout.TextField(strSphBoundsMaxX, GUILayout.MinWidth(60.0F), GUILayout.MaxWidth(60.0F)); strSphBoundsMaxY = GUILayout.TextField(strSphBoundsMaxY, GUILayout.MinWidth(60.0F), GUILayout.MaxWidth(60.0F)); strSphBoundsMaxZ = GUILayout.TextField(strSphBoundsMaxZ, GUILayout.MinWidth(60.0F), GUILayout.MaxWidth(60.0F)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label(""); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Save", GUILayout.Width(125.0f))) { writeConfig(newconfig); GUIToggle(); } if (GUILayout.Button("Cancel", GUILayout.Width(125.0f))) { GUIToggle(); } GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.EndArea(); try { newconfig.keyForward = (KeyCode)Enum.Parse(typeof(KeyCode), strkeyForward); } catch (Exception) { } try { newconfig.keyBack = (KeyCode)Enum.Parse(typeof(KeyCode), strkeyBack); } catch (Exception) { } try { newconfig.keyRight = (KeyCode)Enum.Parse(typeof(KeyCode), strkeyRight); } catch (Exception) { } try { newconfig.keyLeft = (KeyCode)Enum.Parse(typeof(KeyCode), strkeyLeft); } catch (Exception) { } try { newconfig.keyUp = (KeyCode)Enum.Parse(typeof(KeyCode), strkeyUp); } catch (Exception) { } try { newconfig.keyDown = (KeyCode)Enum.Parse(typeof(KeyCode), strkeyDown); } catch (Exception) { } try { newconfig.keyRun = (KeyCode)Enum.Parse(typeof(KeyCode), strkeyRun); } catch (Exception) { } try { newconfig.keySneak = (KeyCode)Enum.Parse(typeof(KeyCode), strkeySneak); } catch (Exception) { } try { newconfig.keySwitchMode = (KeyCode)Enum.Parse(typeof(KeyCode), strkeySwitchMode); } catch (Exception) { } try { newconfig.sensitivity = Convert.ToSingle(strsensitivity); } catch (Exception) { } try { newconfig.acceleration = Convert.ToSingle(stracceleration); } catch (Exception) { } try { newconfig.mouseWheelAcceleration = Convert.ToSingle(strmouseWheelAcceleration); } catch (Exception) { } try { newconfig.friction = Convert.ToSingle(strfriction); } catch (Exception) { } try { newconfig.runMultiplier = Convert.ToSingle(strrunMultiplier); } catch (Exception) { } try { newconfig.sneakMultiplier = Convert.ToSingle(strsneakMultiplier); } catch (Exception) { } try { newconfig.vab.initialPosition.x = Convert.ToSingle(strVabInitPosX); } catch (Exception) { } try { newconfig.vab.initialPosition.y = Convert.ToSingle(strVabInitPosY); } catch (Exception) { } try { newconfig.vab.initialPosition.z = Convert.ToSingle(strVabInitPosZ); } catch (Exception) { } try { newconfig.vab.initialPitch = Convert.ToSingle(strVabInitPitch); } catch (Exception) { } try { newconfig.vab.initialYaw = Convert.ToSingle(strVabInitYaw); } catch (Exception) { } float x, y, z; try { x = Convert.ToSingle(strVabBoundsMinX); y = Convert.ToSingle(strVabBoundsMinY); z = Convert.ToSingle(strVabBoundsMinZ); newconfig.vab.bounds.min = new Vector3(x, y, z); } catch (Exception) { } try { x = Convert.ToSingle(strVabBoundsMaxX); y = Convert.ToSingle(strVabBoundsMaxY); z = Convert.ToSingle(strVabBoundsMaxZ); newconfig.vab.bounds.max = new Vector3(x, y, z); } catch (Exception) { } try { newconfig.sph.initialPosition.x = Convert.ToSingle(strSphInitPosX); } catch (Exception) { } try { newconfig.sph.initialPosition.y = Convert.ToSingle(strSphInitPosY); } catch (Exception) { } try { newconfig.sph.initialPosition.z = Convert.ToSingle(strSphInitPosZ); } catch (Exception) { } try { newconfig.sph.initialPitch = Convert.ToSingle(strSphInitPitch); } catch (Exception) { } try { newconfig.sph.initialYaw = Convert.ToSingle(strSphInitYaw); } catch (Exception) { } try { x = Convert.ToSingle(strSphBoundsMinX); y = Convert.ToSingle(strSphBoundsMinY); z = Convert.ToSingle(strSphBoundsMinZ); newconfig.sph.bounds.min = new Vector3(x, y, z); } catch (Exception) { } try { x = Convert.ToSingle(strSphBoundsMaxX); y = Convert.ToSingle(strSphBoundsMaxY); z = Convert.ToSingle(strSphBoundsMaxZ); newconfig.sph.bounds.max = new Vector3(x, y, z); } catch (Exception) { } GUI.DragWindow(); }
public WasdEditorCameraBehaviour.Config parseConfigNode(ConfigNode root) { WasdEditorCameraBehaviour.Config config = new WasdEditorCameraBehaviour.Config(); try { config.enableExperimentalEditorExtensionsCompatibility = Boolean.Parse(root.GetValue("enableExperimentalEditorExtensionsCompatibility")); } catch { } try { config.defaultCamera = Boolean.Parse(root.GetValue("defaultCamera")); } catch { } try { config.mouseWheelActive = Boolean.Parse(root.GetValue("mouseWheelActive")); } catch { } try { config.enforceBounds = Boolean.Parse(root.GetValue("enforceBounds")); } catch { } try { config.sensitivity = Single.Parse(root.GetValue("sensitivity")); } catch { } try { config.acceleration = Single.Parse(root.GetValue("acceleration")); } catch { } try { config.mouseWheelAcceleration = Single.Parse(root.GetValue("mouseWheelAcceleration")); } catch { } try { config.friction = Single.Parse(root.GetValue("friction")); } catch { } try { config.runMultiplier = Single.Parse(root.GetValue("runMultiplier")); } catch { } try { config.sneakMultiplier = Single.Parse(root.GetValue("sneakMultiplier")); } catch { } var keys = root.GetNode("KEYS"); try { config.keyForward = (KeyCode)ConfigNode.ParseEnum(typeof(KeyCode), keys.GetValue("forward")); } catch { } try { config.keyBack = (KeyCode)ConfigNode.ParseEnum(typeof(KeyCode), keys.GetValue("back")); } catch { } try { config.keyRight = (KeyCode)ConfigNode.ParseEnum(typeof(KeyCode), keys.GetValue("right")); } catch { } try { config.keyLeft = (KeyCode)ConfigNode.ParseEnum(typeof(KeyCode), keys.GetValue("left")); } catch { } try { config.keyUp = (KeyCode)ConfigNode.ParseEnum(typeof(KeyCode), keys.GetValue("up")); } catch { } try { config.keyDown = (KeyCode)ConfigNode.ParseEnum(typeof(KeyCode), keys.GetValue("down")); } catch { } try { config.keyRun = (KeyCode)ConfigNode.ParseEnum(typeof(KeyCode), keys.GetValue("run")); } catch { } try { config.keySneak = (KeyCode)ConfigNode.ParseEnum(typeof(KeyCode), keys.GetValue("sneak")); } catch { } try { config.keySwitchMode = (KeyCode)ConfigNode.ParseEnum(typeof(KeyCode), keys.GetValue("switchMode")); } catch { } var editors = root.GetNode("EDITORS"); try { config.vab = ParseEditorConfig(editors.GetNode("VAB")); } catch { } try { config.sph = ParseEditorConfig(editors.GetNode("SPH")); } catch { } //log.Debug ("Config loaded."); return(config); }
private void writeConfig(WasdEditorCameraBehaviour.Config config) { ConfigNode root = new ConfigNode(); ConfigNode top = new ConfigNode(WASD_NODENAME); root.SetNode(WASD_NODENAME, top, true); top.SetValue("defaultCamera", config.defaultCamera.ToString(), true); top.SetValue("mouseWheelActive", config.mouseWheelActive.ToString(), true); top.SetValue("enableExperimentalEditorExtensionsCompatibility", config.enableExperimentalEditorExtensionsCompatibility.ToString(), true); top.SetValue("enforceBounds", config.enforceBounds.ToString(), true); top.SetValue("sensitivity", config.sensitivity.ToString(), true); top.SetValue("acceleration", config.acceleration.ToString(), true); top.SetValue("mouseWheelAcceleration", config.mouseWheelAcceleration.ToString(), true); top.SetValue("friction", config.friction.ToString(), true); top.SetValue("runMultiplier", config.runMultiplier.ToString(), true); top.SetValue("sneakMultiplier", config.sneakMultiplier.ToString(), true); ConfigNode keysNode = new ConfigNode("KEYS"); top.SetNode("KEYS", keysNode, true); keysNode.SetValue("forward", config.keyForward.ToString(), true); keysNode.SetValue("back", config.keyBack.ToString(), true); keysNode.SetValue("right", config.keyRight.ToString(), true); keysNode.SetValue("left", config.keyLeft.ToString(), true); keysNode.SetValue("up", config.keyUp.ToString(), true); keysNode.SetValue("down", config.keyDown.ToString(), true); keysNode.SetValue("switchMode", config.keySwitchMode.ToString(), true); keysNode.SetValue("run", config.keyRun.ToString(), true); keysNode.SetValue("sneak", config.keySneak.ToString(), true); ConfigNode editorsNode = new ConfigNode("EDITORS"); top.SetNode("EDITORS", editorsNode, true); ConfigNode vabNode = new ConfigNode("VAB"); editorsNode.SetNode("VAB", vabNode, true); string s; s = config.vab.initialPosition.ToString(); s = s.TrimStart('('); s = s.TrimEnd(')'); vabNode.SetValue("initialPosition", s, true); vabNode.SetValue("initialPitch", config.vab.initialPitch.ToString(), true); vabNode.SetValue("initialYaw", config.vab.initialYaw.ToString(), true); ConfigNode vabBoundsNode = new ConfigNode("BOUNDS"); vabNode.SetNode("BOUNDS", vabBoundsNode, true); s = config.vab.bounds.min.ToString(); s = s.TrimStart('('); s = s.TrimEnd(')'); vabBoundsNode.SetValue("min", s, true); s = config.vab.bounds.max.ToString(); s = s.TrimStart('('); s = s.TrimEnd(')'); vabBoundsNode.SetValue("max", s, true); // need to do bounds ConfigNode sphNode = new ConfigNode("SPH"); editorsNode.SetNode("SPH", sphNode, true); s = config.sph.initialPosition.ToString(); s = s.TrimStart('('); s = s.TrimEnd(')'); sphNode.SetValue("initialPosition", s, true); sphNode.SetValue("initialPitch", config.sph.initialPitch.ToString(), true); sphNode.SetValue("initialYaw", config.sph.initialYaw.ToString(), true); // need to do bounds ConfigNode sphBoundsNode = new ConfigNode("BOUNDS"); sphNode.SetNode("BOUNDS", sphBoundsNode, true); s = config.sph.bounds.min.ToString(); s = s.TrimStart('('); s = s.TrimEnd(')'); sphBoundsNode.SetValue("min", s, true); s = config.sph.bounds.max.ToString(); s = s.TrimStart('('); s = s.TrimEnd(')'); sphBoundsNode.SetValue("max", s, true); root.Save(WASD_CFG_FILE); WasdEditorCameraBehaviour.setConfig(root); }
private void Window(int id) { if (cfgWinData == false) { cfgWinData = true; if (!defaultsLoaded) newconfig = WasdEditorCameraBehaviour.config; defaultsLoaded = false; strkeyForward = newconfig.keyForward.ToString (); strkeyBack = newconfig.keyBack.ToString (); strkeyRight = newconfig.keyRight.ToString (); strkeyLeft = newconfig.keyLeft.ToString (); strkeyUp = newconfig.keyUp.ToString (); strkeyDown = newconfig.keyDown.ToString (); strkeyRun = newconfig.keyRun.ToString (); strkeySneak = newconfig.keySneak.ToString (); strkeySwitchMode = newconfig.keySwitchMode.ToString (); #if true cbkeyForward.SetSelectedItemIndex (strkeyForward, comboBoxList); cbkeyBack.SetSelectedItemIndex (strkeyBack, comboBoxList); cbkeyRight.SetSelectedItemIndex (strkeyRight, comboBoxList); cbkeyLeft.SetSelectedItemIndex (strkeyLeft, comboBoxList); cbkeyUp.SetSelectedItemIndex (strkeyUp, comboBoxList); cbkeyDown.SetSelectedItemIndex (strkeyDown, comboBoxList); cbkeyRun.SetSelectedItemIndex (strkeyRun, comboBoxList); cbkeySneak.SetSelectedItemIndex (strkeySneak, comboBoxList); cbkeySwitchMode.SetSelectedItemIndex (strkeySwitchMode, comboBoxList); #endif strsensitivity = newconfig.sensitivity.ToString (); stracceleration = newconfig.acceleration.ToString (); strmouseWheelAcceleration = newconfig.mouseWheelAcceleration.ToString (); strfriction = newconfig.friction.ToString (); strrunMultiplier = newconfig.runMultiplier.ToString (); strsneakMultiplier = newconfig.sneakMultiplier.ToString (); strVabInitPosX = newconfig.vab.initialPosition.x.ToString (); strVabInitPosY = newconfig.vab.initialPosition.y.ToString (); strVabInitPosZ = newconfig.vab.initialPosition.z.ToString (); strVabInitPitch = newconfig.vab.initialPitch.ToString (); strVabInitYaw = newconfig.vab.initialYaw.ToString (); strVabBoundsMinX = newconfig.vab.bounds.min.x.ToString (); strVabBoundsMinY = newconfig.vab.bounds.min.y.ToString (); strVabBoundsMinZ = newconfig.vab.bounds.min.z.ToString (); strVabBoundsMaxX = newconfig.vab.bounds.max.x.ToString (); strVabBoundsMaxY = newconfig.vab.bounds.max.y.ToString (); strVabBoundsMaxZ = newconfig.vab.bounds.max.z.ToString (); strSphInitPosX = newconfig.sph.initialPosition.x.ToString (); strSphInitPosY = newconfig.sph.initialPosition.y.ToString (); strSphInitPosZ = newconfig.sph.initialPosition.z.ToString (); strSphInitPitch = newconfig.sph.initialPitch.ToString (); strSphInitYaw = newconfig.sph.initialYaw.ToString (); strSphBoundsMinX = newconfig.sph.bounds.min.x.ToString (); strSphBoundsMinY = newconfig.sph.bounds.min.y.ToString (); strSphBoundsMinZ = newconfig.sph.bounds.min.z.ToString (); strSphBoundsMaxX = newconfig.sph.bounds.max.x.ToString (); strSphBoundsMaxY = newconfig.sph.bounds.max.y.ToString (); strSphBoundsMaxZ = newconfig.sph.bounds.max.z.ToString (); } SetVisible (true); GUI.enabled = true; GUILayout.BeginHorizontal (); GUILayout.EndHorizontal (); GUILayout.BeginArea (new Rect (10, 50, 375, 500)); GUILayout.BeginVertical (); DrawTitle ("Keys"); GUILayout.BeginHorizontal (); GUILayout.Label ("Key forward: "); #if true // GUILayout.BeginArea (new Rect (10, 20, 300, 500)); // strkeyForward = comboBoxList[cbkeyForward.List (new Rect (125, 5, 150, 20), strkeyForward, comboBoxList, listStyle)].text; // GUILayout.EndArea (); #else GUILayout.FlexibleSpace (); strkeyForward = GUILayout.TextField (strkeyForward, GUILayout.MinWidth (60.0F), GUILayout.MaxWidth (60.0F)); #endif GUILayout.EndHorizontal (); GUILayout.BeginHorizontal (); GUILayout.Label ("Key back: "); #if true // GUILayout.BeginArea (new Rect (10, 45, 300, 500)); // strkeyBack = comboBoxList[cbkeyBack.List (new Rect (125, 5, 150, 20), strkeyBack, comboBoxList, listStyle)].text; // GUILayout.EndArea (); #else GUILayout.FlexibleSpace (); strkeyBack = GUILayout.TextField (strkeyBack, GUILayout.MinWidth (60.0F), GUILayout.MaxWidth (60.0F)); #endif GUILayout.EndHorizontal (); GUILayout.BeginHorizontal (); GUILayout.Label ("Key right: "); #if true // GUILayout.BeginArea (new Rect (10, 70, 300, 500)); // strkeyRight = comboBoxList[cbkeyRight.List (new Rect (125, 5, 150, 20), strkeyRight, comboBoxList, listStyle)].text; // GUILayout.EndArea (); #else GUILayout.FlexibleSpace (); strkeyRight = GUILayout.TextField (strkeyRight, GUILayout.MinWidth (60.0F), GUILayout.MaxWidth (60.0F)); #endif GUILayout.EndHorizontal (); GUILayout.BeginHorizontal (); GUILayout.Label ("Key left: "); #if true // GUILayout.BeginArea (new Rect (10, 95, 300, 500)); // strkeyLeft = comboBoxList[cbkeyLeft.List (new Rect (125, 5, 150, 20), strkeyLeft, comboBoxList, listStyle)].text; // GUILayout.EndArea (); #else GUILayout.FlexibleSpace (); strkeyLeft = GUILayout.TextField (strkeyLeft, GUILayout.MinWidth (60.0F), GUILayout.MaxWidth (60.0F)); #endif GUILayout.EndHorizontal (); GUILayout.BeginHorizontal (); GUILayout.Label ("Key up: "); #if true // GUILayout.BeginArea (new Rect (10, 120, 300, 500)); // strkeyUp = comboBoxList[cbkeyUp.List (new Rect (125, 5, 150, 20), strkeyUp, comboBoxList, listStyle)].text; // GUILayout.EndArea (); #else GUILayout.FlexibleSpace (); strkeyUp = GUILayout.TextField (strkeyUp, GUILayout.MinWidth (60.0F), GUILayout.MaxWidth (60.0F)); #endif GUILayout.EndHorizontal (); GUILayout.BeginHorizontal (); GUILayout.Label ("Key down: "); #if true // GUILayout.BeginArea (new Rect (10, 145, 300, 500)); // strkeyDown = comboBoxList[cbkeyDown.List (new Rect (125, 5, 150, 20), strkeyDown, comboBoxList, listStyle)].text; // GUILayout.EndArea (); #else GUILayout.FlexibleSpace (); strkeyDown = GUILayout.TextField (strkeyDown, GUILayout.MinWidth (60.0F), GUILayout.MaxWidth (60.0F)); #endif GUILayout.EndHorizontal (); GUILayout.BeginHorizontal (); GUILayout.Label ("Key run: "); #if true // GUILayout.BeginArea (new Rect (10, 170, 300, 500)); // strkeyRun = comboBoxList[cbkeyRun.List (new Rect (125, 5, 150, 20), strkeyRun, comboBoxList, listStyle)].text; // GUILayout.EndArea (); #else GUILayout.FlexibleSpace (); strkeyRun = GUILayout.TextField (strkeyRun, GUILayout.MinWidth (60.0F), GUILayout.MaxWidth (60.0F)); #endif GUILayout.EndHorizontal (); GUILayout.BeginHorizontal (); GUILayout.Label ("Key sneak: "); #if true // GUILayout.BeginArea (new Rect (10, 195, 300, 500)); // strkeySneak = comboBoxList[cbkeySneak.List (new Rect (125, 5, 150, 20), strkeySneak, comboBoxList, listStyle)].text; // GUILayout.EndArea (); #else GUILayout.FlexibleSpace (); strkeySneak = GUILayout.TextField (strkeySneak, GUILayout.MinWidth (60.0F), GUILayout.MaxWidth (60.0F)); #endif GUILayout.EndHorizontal (); GUILayout.BeginHorizontal (); GUILayout.Label ("Key switch mode: "); #if true // GUILayout.BeginArea (new Rect (10, 220, 300, 500)); // strkeySwitchMode = comboBoxList[cbkeySwitchMode.List (new Rect (125, 5, 150, 20), strkeySwitchMode, comboBoxList, listStyle)].text; // GUILayout.EndArea (); #else GUILayout.FlexibleSpace (); strkeySwitchMode = GUILayout.TextField (strkeySwitchMode, GUILayout.MinWidth (60.0F), GUILayout.MaxWidth (60.0F)); #endif GUILayout.EndHorizontal (); GUILayout.BeginHorizontal (); GUILayout.Label (""); GUILayout.EndHorizontal (); DrawTitle ("VAB", true); GUILayout.BeginHorizontal (); GUILayout.Label ("Initial Position: "); GUILayout.FlexibleSpace (); strVabInitPosX = GUILayout.TextField (strVabInitPosX, GUILayout.MinWidth (60.0F), GUILayout.MaxWidth (60.0F)); strVabInitPosY = GUILayout.TextField (strVabInitPosY, GUILayout.MinWidth (60.0F), GUILayout.MaxWidth (60.0F)); strVabInitPosZ = GUILayout.TextField (strVabInitPosZ, GUILayout.MinWidth (60.0F), GUILayout.MaxWidth (60.0F)); GUILayout.EndHorizontal (); GUILayout.BeginHorizontal (); GUILayout.Label ("Initial Pitch: "); GUILayout.FlexibleSpace (); strVabInitPitch = GUILayout.TextField (strVabInitPitch, GUILayout.MinWidth (60.0F), GUILayout.MaxWidth (60.0F)); GUILayout.EndHorizontal (); GUILayout.BeginHorizontal (); GUILayout.Label ("Initial Yaw: "); GUILayout.FlexibleSpace (); strVabInitYaw = GUILayout.TextField (strVabInitYaw, GUILayout.MinWidth (60.0F), GUILayout.MaxWidth (60.0F)); GUILayout.EndHorizontal (); GUILayout.BeginHorizontal (); GUILayout.Label ("Bounds min: "); GUILayout.FlexibleSpace (); // x, y, z strVabBoundsMinX = GUILayout.TextField (strVabBoundsMinX, GUILayout.MinWidth (60.0F), GUILayout.MaxWidth (60.0F)); strVabBoundsMinY = GUILayout.TextField (strVabBoundsMinY, GUILayout.MinWidth (60.0F), GUILayout.MaxWidth (60.0F)); strVabBoundsMinZ = GUILayout.TextField (strVabBoundsMinZ, GUILayout.MinWidth (60.0F), GUILayout.MaxWidth (60.0F)); GUILayout.EndHorizontal (); GUILayout.BeginHorizontal (); GUILayout.Label ("Bounds max: "); GUILayout.FlexibleSpace (); // x, y, z strVabBoundsMaxX = GUILayout.TextField (strVabBoundsMaxX, GUILayout.MinWidth (60.0F), GUILayout.MaxWidth (60.0F)); strVabBoundsMaxY = GUILayout.TextField (strVabBoundsMaxY, GUILayout.MinWidth (60.0F), GUILayout.MaxWidth (60.0F)); strVabBoundsMaxZ = GUILayout.TextField (strVabBoundsMaxZ, GUILayout.MinWidth (60.0F), GUILayout.MaxWidth (60.0F)); GUILayout.EndHorizontal (); GUILayout.BeginHorizontal (); GUILayout.Label (""); GUILayout.EndHorizontal (); GUILayout.BeginHorizontal (); if (GUILayout.Button ("Defaults", GUILayout.Width (125.0f))) { SetDefaults (); } GUILayout.EndHorizontal (); /////////////////////////////////////////////// /// These have to be here so that when they are clicked on, they will overwrite the other controls in the column /// GUILayout.BeginArea (new Rect (10, 20, 300, 500)); strkeyForward = comboBoxList [cbkeyForward.List (new Rect (125, 5, 150, 20), strkeyForward, comboBoxList, listStyle)].text; GUILayout.EndArea (); GUILayout.BeginArea (new Rect (10, 45, 300, 500)); strkeyBack = comboBoxList [cbkeyBack.List (new Rect (125, 5, 150, 20), strkeyBack, comboBoxList, listStyle)].text; GUILayout.EndArea (); GUILayout.BeginArea (new Rect (10, 70, 300, 500)); strkeyRight = comboBoxList [cbkeyRight.List (new Rect (125, 5, 150, 20), strkeyRight, comboBoxList, listStyle)].text; GUILayout.EndArea (); GUILayout.BeginArea (new Rect (10, 95, 300, 500)); strkeyLeft = comboBoxList [cbkeyLeft.List (new Rect (125, 5, 150, 20), strkeyLeft, comboBoxList, listStyle)].text; GUILayout.EndArea (); GUILayout.BeginArea (new Rect (10, 120, 300, 500)); strkeyUp = comboBoxList [cbkeyUp.List (new Rect (125, 5, 150, 20), strkeyUp, comboBoxList, listStyle)].text; GUILayout.EndArea (); GUILayout.BeginArea (new Rect (10, 145, 300, 500)); strkeyDown = comboBoxList [cbkeyDown.List (new Rect (125, 5, 150, 20), strkeyDown, comboBoxList, listStyle)].text; GUILayout.EndArea (); GUILayout.BeginArea (new Rect (10, 170, 300, 500)); strkeyRun = comboBoxList [cbkeyRun.List (new Rect (125, 5, 150, 20), strkeyRun, comboBoxList, listStyle)].text; GUILayout.EndArea (); GUILayout.BeginArea (new Rect (10, 195, 300, 500)); strkeySneak = comboBoxList [cbkeySneak.List (new Rect (125, 5, 150, 20), strkeySneak, comboBoxList, listStyle)].text; GUILayout.EndArea (); GUILayout.BeginArea (new Rect (10, 220, 300, 500)); strkeySwitchMode = comboBoxList [cbkeySwitchMode.List (new Rect (125, 5, 150, 20), strkeySwitchMode, comboBoxList, listStyle)].text; GUILayout.EndArea (); GUILayout.EndVertical (); GUILayout.EndArea (); GUILayout.BeginArea (new Rect (400, 50, 300, 500)); GUILayout.BeginVertical (); DrawTitle ("Misc"); GUILayout.BeginHorizontal (); GUILayout.Label ("Exp Editor Ext. Compatibility: "); GUILayout.FlexibleSpace (); newconfig.enableExperimentalEditorExtensionsCompatibility = GUILayout.Toggle (newconfig.enableExperimentalEditorExtensionsCompatibility, ""); GUILayout.EndHorizontal (); GUILayout.BeginHorizontal (); GUILayout.Label ("Default Camera: "); GUILayout.FlexibleSpace (); newconfig.defaultCamera = GUILayout.Toggle (newconfig.defaultCamera, ""); GUILayout.EndHorizontal (); GUILayout.BeginHorizontal (); GUILayout.Label ("Mouse wheel active: "); GUILayout.FlexibleSpace (); newconfig.mouseWheelActive = GUILayout.Toggle (newconfig.mouseWheelActive, ""); GUILayout.EndHorizontal (); GUILayout.BeginHorizontal (); GUILayout.Label ("Enforce bounds: "); GUILayout.FlexibleSpace (); newconfig.enforceBounds = GUILayout.Toggle (newconfig.enforceBounds, ""); GUILayout.EndHorizontal (); GUILayout.BeginHorizontal (); GUILayout.Label ("Sensitivity: "); GUILayout.FlexibleSpace (); strsensitivity = GUILayout.TextField (strsensitivity, GUILayout.MinWidth (60.0F), GUILayout.MaxWidth (60.0F)); GUILayout.EndHorizontal (); GUILayout.BeginHorizontal (); GUILayout.Label ("Acceleration: "); GUILayout.FlexibleSpace (); stracceleration = GUILayout.TextField (stracceleration, GUILayout.MinWidth (60.0F), GUILayout.MaxWidth (60.0F)); GUILayout.EndHorizontal (); GUILayout.BeginHorizontal (); GUILayout.Label ("Mouse wheel acceleration: "); GUILayout.FlexibleSpace (); strmouseWheelAcceleration = GUILayout.TextField (strmouseWheelAcceleration, GUILayout.MinWidth (60.0F), GUILayout.MaxWidth (60.0F)); GUILayout.EndHorizontal (); GUILayout.BeginHorizontal (); GUILayout.Label ("Friction: "); GUILayout.FlexibleSpace (); strfriction = GUILayout.TextField (strfriction, GUILayout.MinWidth (60.0F), GUILayout.MaxWidth (60.0F)); GUILayout.EndHorizontal (); GUILayout.BeginHorizontal (); GUILayout.Label ("Run multiplier: "); GUILayout.FlexibleSpace (); strrunMultiplier = GUILayout.TextField (strrunMultiplier, GUILayout.MinWidth (60.0F), GUILayout.MaxWidth (60.0F)); GUILayout.EndHorizontal (); GUILayout.BeginHorizontal (); GUILayout.Label ("Sneak multiplier: "); GUILayout.FlexibleSpace (); strsneakMultiplier = GUILayout.TextField (strsneakMultiplier, GUILayout.MinWidth (60.0F), GUILayout.MaxWidth (60.0F)); GUILayout.EndHorizontal (); //GUILayout.BeginHorizontal (); //GUILayout.Label (""); //GUILayout.EndHorizontal (); DrawTitle ("SPH", true); GUILayout.BeginHorizontal (); GUILayout.Label ("Initial Position: "); GUILayout.FlexibleSpace (); strSphInitPosX = GUILayout.TextField (strSphInitPosX, GUILayout.MinWidth (60.0F), GUILayout.MaxWidth (60.0F)); strSphInitPosY = GUILayout.TextField (strSphInitPosY, GUILayout.MinWidth (60.0F), GUILayout.MaxWidth (60.0F)); strSphInitPosZ = GUILayout.TextField (strSphInitPosZ, GUILayout.MinWidth (60.0F), GUILayout.MaxWidth (60.0F)); GUILayout.EndHorizontal (); GUILayout.BeginHorizontal (); GUILayout.Label ("Initial Pitch: "); GUILayout.FlexibleSpace (); strSphInitPitch = GUILayout.TextField (strSphInitPitch, GUILayout.MinWidth (60.0F), GUILayout.MaxWidth (60.0F)); GUILayout.EndHorizontal (); GUILayout.BeginHorizontal (); GUILayout.Label ("Initial Yaw: "); GUILayout.FlexibleSpace (); strSphInitYaw = GUILayout.TextField (strSphInitYaw, GUILayout.MinWidth (60.0F), GUILayout.MaxWidth (60.0F)); GUILayout.EndHorizontal (); GUILayout.BeginHorizontal (); GUILayout.Label ("Bounds min: "); GUILayout.FlexibleSpace (); // x, y, z strSphBoundsMinX = GUILayout.TextField (strSphBoundsMinX, GUILayout.MinWidth (60.0F), GUILayout.MaxWidth (60.0F)); strSphBoundsMinY = GUILayout.TextField (strSphBoundsMinY, GUILayout.MinWidth (60.0F), GUILayout.MaxWidth (60.0F)); strSphBoundsMinZ = GUILayout.TextField (strSphBoundsMinZ, GUILayout.MinWidth (60.0F), GUILayout.MaxWidth (60.0F)); GUILayout.EndHorizontal (); GUILayout.BeginHorizontal (); GUILayout.Label ("Bounds max: "); GUILayout.FlexibleSpace (); // x, y, z strSphBoundsMaxX = GUILayout.TextField (strSphBoundsMaxX, GUILayout.MinWidth (60.0F), GUILayout.MaxWidth (60.0F)); strSphBoundsMaxY = GUILayout.TextField (strSphBoundsMaxY, GUILayout.MinWidth (60.0F), GUILayout.MaxWidth (60.0F)); strSphBoundsMaxZ = GUILayout.TextField (strSphBoundsMaxZ, GUILayout.MinWidth (60.0F), GUILayout.MaxWidth (60.0F)); GUILayout.EndHorizontal (); GUILayout.BeginHorizontal (); GUILayout.Label (""); GUILayout.EndHorizontal (); GUILayout.BeginHorizontal (); if (GUILayout.Button ("Save", GUILayout.Width (125.0f))) { writeConfig (newconfig); GUIToggle (); } if (GUILayout.Button ("Cancel", GUILayout.Width (125.0f))) { GUIToggle (); } GUILayout.EndHorizontal (); GUILayout.EndVertical (); GUILayout.EndArea (); try { newconfig.keyForward = (KeyCode)Enum.Parse (typeof(KeyCode), strkeyForward); } catch (Exception) { } try { newconfig.keyBack = (KeyCode)Enum.Parse (typeof(KeyCode), strkeyBack); } catch (Exception) { } try { newconfig.keyRight = (KeyCode)Enum.Parse (typeof(KeyCode), strkeyRight); } catch (Exception) { } try { newconfig.keyLeft = (KeyCode)Enum.Parse (typeof(KeyCode), strkeyLeft); } catch (Exception) { } try { newconfig.keyUp = (KeyCode)Enum.Parse (typeof(KeyCode), strkeyUp); } catch (Exception) { } try { newconfig.keyDown = (KeyCode)Enum.Parse (typeof(KeyCode), strkeyDown); } catch (Exception) { } try { newconfig.keyRun = (KeyCode)Enum.Parse (typeof(KeyCode), strkeyRun); } catch (Exception) { } try { newconfig.keySneak = (KeyCode)Enum.Parse (typeof(KeyCode), strkeySneak); } catch (Exception) { } try { newconfig.keySwitchMode = (KeyCode)Enum.Parse (typeof(KeyCode), strkeySwitchMode); } catch (Exception) { } try { newconfig.sensitivity = Convert.ToSingle (strsensitivity); } catch (Exception) { } try { newconfig.acceleration = Convert.ToSingle (stracceleration); } catch (Exception) { } try { newconfig.mouseWheelAcceleration = Convert.ToSingle (strmouseWheelAcceleration); } catch (Exception) { } try { newconfig.friction = Convert.ToSingle (strfriction); } catch (Exception) { } try { newconfig.runMultiplier = Convert.ToSingle (strrunMultiplier); } catch (Exception) { } try { newconfig.sneakMultiplier = Convert.ToSingle (strsneakMultiplier); } catch (Exception) { } try { newconfig.vab.initialPosition.x = Convert.ToSingle (strVabInitPosX); } catch (Exception) { } try { newconfig.vab.initialPosition.y = Convert.ToSingle (strVabInitPosY); } catch (Exception) { } try { newconfig.vab.initialPosition.z = Convert.ToSingle (strVabInitPosZ); } catch (Exception) { } try { newconfig.vab.initialPitch = Convert.ToSingle (strVabInitPitch); } catch (Exception) { } try { newconfig.vab.initialYaw = Convert.ToSingle (strVabInitYaw); } catch (Exception) { } float x, y, z; try { x = Convert.ToSingle (strVabBoundsMinX); y = Convert.ToSingle (strVabBoundsMinY); z = Convert.ToSingle (strVabBoundsMinZ); newconfig.vab.bounds.min = new Vector3 (x, y, z); } catch (Exception) { } try { x = Convert.ToSingle (strVabBoundsMaxX); y = Convert.ToSingle (strVabBoundsMaxY); z = Convert.ToSingle (strVabBoundsMaxZ); newconfig.vab.bounds.max = new Vector3 (x, y, z); } catch (Exception) { } try { newconfig.sph.initialPosition.x = Convert.ToSingle (strSphInitPosX); } catch (Exception) { } try { newconfig.sph.initialPosition.y = Convert.ToSingle (strSphInitPosY); } catch (Exception) { } try { newconfig.sph.initialPosition.z = Convert.ToSingle (strSphInitPosZ); } catch (Exception) { } try { newconfig.sph.initialPitch = Convert.ToSingle (strSphInitPitch); } catch (Exception) { } try { newconfig.sph.initialYaw = Convert.ToSingle (strSphInitYaw); } catch (Exception) { } try { x = Convert.ToSingle (strSphBoundsMinX); y = Convert.ToSingle (strSphBoundsMinY); z = Convert.ToSingle (strSphBoundsMinZ); newconfig.sph.bounds.min = new Vector3 (x, y, z); } catch (Exception) { } try { x = Convert.ToSingle (strSphBoundsMaxX); y = Convert.ToSingle (strSphBoundsMaxY); z = Convert.ToSingle (strSphBoundsMaxZ); newconfig.sph.bounds.max = new Vector3 (x, y, z); } catch (Exception) { } GUI.DragWindow (); }
void SetDefaults() { string fname = WASD_CFG_FILE + ".default"; if (System.IO.File.Exists (fname)) { ConfigNode file = ConfigNode.Load (fname); var root = file.GetNode (WASD_NODENAME); newconfig = parseConfigNode (root); cfgWinData = false; defaultsLoaded = true; } //newconfig = configFile; }
public WasdEditorCameraBehaviour.Config parseConfigNode(ConfigNode root) { WasdEditorCameraBehaviour.Config config = new WasdEditorCameraBehaviour.Config (); try { config.enableExperimentalEditorExtensionsCompatibility = Boolean.Parse (root.GetValue ("enableExperimentalEditorExtensionsCompatibility")); } catch { } try { config.defaultCamera = Boolean.Parse (root.GetValue ("defaultCamera")); } catch { } try { config.mouseWheelActive = Boolean.Parse (root.GetValue ("mouseWheelActive")); } catch { } try { config.enforceBounds = Boolean.Parse (root.GetValue ("enforceBounds")); } catch { } try { config.sensitivity = Single.Parse (root.GetValue ("sensitivity")); } catch { } try { config.acceleration = Single.Parse (root.GetValue ("acceleration")); } catch { } try { config.mouseWheelAcceleration = Single.Parse (root.GetValue ("mouseWheelAcceleration")); } catch { } try { config.friction = Single.Parse (root.GetValue ("friction")); } catch { } try { config.runMultiplier = Single.Parse (root.GetValue ("runMultiplier")); } catch { } try { config.sneakMultiplier = Single.Parse (root.GetValue ("sneakMultiplier")); } catch { } var keys = root.GetNode ("KEYS"); try { config.keyForward = (KeyCode)ConfigNode.ParseEnum (typeof(KeyCode), keys.GetValue ("forward")); } catch { } try { config.keyBack = (KeyCode)ConfigNode.ParseEnum (typeof(KeyCode), keys.GetValue ("back")); } catch { } try { config.keyRight = (KeyCode)ConfigNode.ParseEnum (typeof(KeyCode), keys.GetValue ("right")); } catch { } try { config.keyLeft = (KeyCode)ConfigNode.ParseEnum (typeof(KeyCode), keys.GetValue ("left")); } catch { } try { config.keyUp = (KeyCode)ConfigNode.ParseEnum (typeof(KeyCode), keys.GetValue ("up")); } catch { } try { config.keyDown = (KeyCode)ConfigNode.ParseEnum (typeof(KeyCode), keys.GetValue ("down")); } catch { } try { config.keyRun = (KeyCode)ConfigNode.ParseEnum (typeof(KeyCode), keys.GetValue ("run")); } catch { } try { config.keySneak = (KeyCode)ConfigNode.ParseEnum (typeof(KeyCode), keys.GetValue ("sneak")); } catch { } try { config.keySwitchMode = (KeyCode)ConfigNode.ParseEnum (typeof(KeyCode), keys.GetValue ("switchMode")); } catch { } var editors = root.GetNode ("EDITORS"); try { config.vab = ParseEditorConfig (editors.GetNode ("VAB")); } catch { } try { config.sph = ParseEditorConfig (editors.GetNode ("SPH")); } catch { } //log.Debug ("Config loaded."); return config; }