private void SaveProfiles() { _EditMode = EEditMode.None; CProfiles.SaveProfiles(); LoadProfiles(); UpdateGame(); }
public virtual void OnHotspotChanged(CGizmo oGizmo, EEditMode eEditMode, EHotSpotOp eHotSpotOp) { switch (eEditMode) { case EEditMode.Move: //###NOTE: We don't process rotation as the game only supports 0 or 180 Y rotation transform.position = oGizmo.transform.position; break; } }
void OnEnable() { ClearInputText(); ClearSuggestions(); SetFocus(); ResetBrowse(); EditMode = EEditMode.User; }
////////////////////////////////////////////////////////////////////// // Update text box helper functions private void SetInputText(string str, EEditMode editMode) { if (InputText && str != InputText.text) { EditMode = editMode; InputText.text = str; InputText.caretPosition = int.MaxValue; } }
private void _SaveProfiles() { _EditMode = EEditMode.None; string _NewProfileName = CProfiles.GetPlayerName(_NewProfileID); if (_NewProfileName.Length > 1) { CProfiles.SaveProfiles(); } _ProfilesChanged = true; }
public void OnValueChanged(string value) { if (EditMode == EEditMode.User || EditMode == EEditMode.Clear) { UserInput = value; UserInputTerms = Utils.GetCommandTerms(value); ResetBrowse(); } UpdateSuggestions(); EditMode = EEditMode.User; }
protected override void Init() { base.Init(); _ThemeName = "ScreenProfiles"; _ScreenVersion = ScreenVersion; _ThemeButtons = new string[] { ButtonPlayerName, ButtonExit, ButtonSave, ButtonNew, ButtonDelete }; _ThemeSelectSlides = new string[] { SelectSlideProfiles, SelectSlideDifficulty, SelectSlideAvatars, SelectSlideGuestProfile, SelectSlideActive }; _ThemeStatics = new string[] { StaticAvatar }; _EditMode = EEditMode.None; }
protected override void Init() { base.Init(); _ThemeName = "ScreenProfiles"; _ScreenVersion = ScreenVersion; _ThemeButtons = new string[] { ButtonPlayerName, ButtonExit, ButtonSave, ButtonNew, ButtonDelete, ButtonWebcam, ButtonSaveSnapshot, ButtonDiscardSnapshot, ButtonTakeSnapshot }; _ThemeSelectSlides = new string[] { SelectSlideProfiles, SelectSlideDifficulty, SelectSlideAvatars, SelectSlideGuestProfile, SelectSlideActive }; _ThemeStatics = new string[] { StaticAvatar }; _EditMode = EEditMode.None; }
private void NewProfile() { _EditMode = EEditMode.None; CProfiles.NewProfile(); LoadProfiles(); SelectSlides[htSelectSlides(SelectSlideProfiles)].LastValue(); CProfiles.SetAvatar(SelectSlides[htSelectSlides(SelectSlideProfiles)].Selection, SelectSlides[htSelectSlides(SelectSlideAvatars)].Selection); SetInteractionToButton(Buttons[htButtons(ButtonPlayerName)]); _EditMode = EEditMode.PlayerName; }
private void _NewProfile() { _EditMode = EEditMode.None; Guid id = CProfiles.NewProfile(); //_LoadProfiles(false); _NewProfileID = id; CProfiles.SetAvatar(_NewProfileID, _SelectSlides[_SelectSlideAvatars].SelectedTag); _SelectElement(_Buttons[_ButtonPlayerName]); //_EditMode = EEditMode.PlayerName; }
public override void Init() { base.Init(); _ThemeButtons = new string[] { _ButtonPlayerName, _ButtonExit, _ButtonSave, _ButtonNew, _ButtonDelete, _ButtonWebcam, _ButtonSaveSnapshot, _ButtonDiscardSnapshot, _ButtonTakeSnapshot }; _ThemeSelectSlides = new string[] { _SelectSlideProfiles, _SelectSlideDifficulty, _SelectSlideAvatars, _SelectSlideUserRole, _SelectSlideActive }; _ThemeStatics = new string[] { _StaticAvatar }; _EditMode = EEditMode.None; _ProfilesChanged = false; _AvatarsChanged = false; CProfiles.AddProfileChangedCallback(_OnProfileChanged); }
void DrawToolBar() { Handles.BeginGUI(); GUILayout.BeginArea(new Rect(10, 10, 480, 40)); m_selectedMode = GUILayout.Toolbar(m_selectedMode, m_toolbarItem, GUILayout.ExpandHeight(true)); GUILayout.EndArea(); Handles.EndGUI(); if ((int)m_currentMode != m_selectedMode) { m_currentMode = (EEditMode)m_selectedMode; } if (m_currentMode == EEditMode.View) { Tools.current = Tool.View; } else { Tools.current = Tool.None; } SceneView.currentDrawingSceneView.in2DMode = true; HandleUtility.AddDefaultControl(GUIUtility.GetControlID(FocusType.Passive)); Camera camera = SceneView.currentDrawingSceneView.camera; Vector3 mousePosition = Event.current.mousePosition; mousePosition = new Vector2(mousePosition.x, camera.pixelHeight - mousePosition.y); Vector3 worldPos = camera.ScreenToWorldPoint(mousePosition); GridPosition gridPos = m_target.PositionToGrid(worldPos); int col = gridPos.col; int row = gridPos.row; Debug.Log(string.Format("{0}, {1}", col, row)); if (m_target.IsValidGrid(col, row) && (Event.current.type == EventType.MouseDown || Event.current.type == EventType.MouseDrag)) { if (m_currentMode == EEditMode.Erase) { Erase(col, row); } else if (m_currentMode != EEditMode.View) { Paint(col, row); } } }
private void _NewProfile() { _EditMode = EEditMode.None; Guid id = CProfiles.NewProfile(); _LoadProfiles(false); int num = CProfiles.NumProfiles; _SelectSlides[_SelectSlideProfiles].SelectedTag = num; _SelectSlideGuids.Add(num, id); CProfiles.SetAvatar(id, _SelectSlides[_SelectSlideAvatars].SelectedTag); _SelectElement(_Buttons[_ButtonPlayerName]); _EditMode = EEditMode.PlayerName; }
private void _DeleteProfile() { _EditMode = EEditMode.None; CProfiles.DeleteProfile(_SelectSlides[_SelectSlideProfiles].SelectedTag); int selection = _SelectSlides[_SelectSlideProfiles].Selection; if (_SelectSlides[_SelectSlideProfiles].NumValues - 1 > selection) { _SelectSlides[_SelectSlideProfiles].Selection = selection + 1; } else { _SelectSlides[_SelectSlideProfiles].Selection = selection - 1; } }
private void LoadProfiles() { _EditMode = EEditMode.None; SelectSlides[htSelectSlides(SelectSlideProfiles)].Clear(); for (int i = 0; i < CProfiles.NumProfiles; i++) { SelectSlides[htSelectSlides(SelectSlideProfiles)].AddValue(CProfiles.GetPlayerName(i)); } if (CProfiles.NumProfiles > 0 && CProfiles.NumAvatars > 0) { SelectSlides[htSelectSlides(SelectSlideDifficulty)].Selection = (int)CProfiles.GetDifficulty(SelectSlides[htSelectSlides(SelectSlideProfiles)].Selection); SelectSlides[htSelectSlides(SelectSlideGuestProfile)].Selection = (int)CProfiles.GetGuestProfile(SelectSlides[htSelectSlides(SelectSlideProfiles)].Selection); SelectSlides[htSelectSlides(SelectSlideActive)].Selection = (int)CProfiles.GetActive(SelectSlides[htSelectSlides(SelectSlideProfiles)].Selection); SelectSlides[htSelectSlides(SelectSlideAvatars)].Selection = CProfiles.GetAvatarNr(SelectSlides[htSelectSlides(SelectSlideProfiles)].Selection); } }
protected override void OnMouseDown(MouseEventArgs e) { Focus(); if (EditMode == EEditMode.EM_None) { if (e.Button == MouseButtons.Right) { Capture = true; EditMode = EEditMode.EM_Translate; LastMovePos[0] = e.X; LastMovePos[1] = e.Y; Cursor = Cursors.NoMove2D; } else if (e.Button == MouseButtons.Left) { /*if (Control.ModifierKeys == Keys.Shift) * { * Capture = true; * EditMode = EEditMode.EM_Translate; * LastMovePos[0] = e.X; * LastMovePos[1] = e.Y; * * Cursor = Cursors.NoMove2D; * } * else */if ((WorkingFrameItem != null) && (Cursor != cursors[0])) { for (int i = 0; i < cursors.Length; i++) { if (cursors[i] == Cursor) { Capture = true; EditMode = EEditMode.EM_Resize; ResizeDir = (EEdgeCorner)i; LastMovePos[0] = e.X; LastMovePos[1] = e.Y; } } } } } }
public override void Init() { base.Init(); _ThemeButtons = new string[] { _ButtonPlayerName, _ButtonCancel, _ButtonSave }; _ThemeSelectSlides = new string[] { _SelectSlideDifficulty, _SelectSlideAvatars }; _ThemeStatics = new string[] { _StaticAvatar }; _EditMode = EEditMode.None; _ProfilesChanged = false; _AvatarsChanged = false; _CursorBlink = false; _Timer = new Timer(); _Timer.Tick += new EventHandler(_TimerEvent); _Timer.Interval = 400; _Timer.Start(); CProfiles.AddProfileChangedCallback(_OnProfileChanged); }
private void GraphEditor_MouseDown(object sender, MouseEventArgs e) { mouseDown = true; lastMousePoint = e.Location; editMode = EEditMode.None; if (e.Button == MouseButtons.Left) { var contextPoint = PointToContext(e.Location); foreach (var n in nodes) { if (new Rectangle(n.X, n.Y, n.Width, n.Height).Contains(contextPoint)) { editMode = EEditMode.MoveNode; selectedNode = n; Invalidate(); return; } else { foreach (var pinIn in n.PinOuts) { if (new Rectangle(pinIn.X, pinIn.Y, pinIn.Width, pinIn.Height).Contains(contextPoint)) { editMode = EEditMode.LinkNode; _selectedPin = pinIn; Invalidate(); return; } } } } } else if (e.Button == MouseButtons.Middle) { editMode = EEditMode.MoveScreen; } }
//--------------------------------------------------------------------------- EVENTS public virtual void OnHotspotChanged(CGizmo oGizmo, EEditMode eEditMode, EHotSpotOp eHotSpotOp) { if (_iHotSpotMgr != null) _iHotSpotMgr.OnHotspotChanged(oGizmo, eEditMode, eHotSpotOp); // Notify our manager that we have changed. }
public void drawEditBox(int posY, int lines, string prompt, string captionOrg, int cursor_position, bool selected, EEditMode mode) { string caption = prompt + captionOrg; drawTextBox(posY, lines, caption, EAlignment.justify_left); if (selected) { switch (mode) { case EEditMode.alphanum_high: drawText(maxColumns - 3, 0, "ABC"); break; case EEditMode.alphanum_low: drawText(maxColumns - 3, 0, "abc"); break; case EEditMode.numeric: drawText(maxColumns - 3, 0, "123"); break; } } if (selected) { formSetCursor(prompt.Length + cursor_position % maxColumns, posY + (cursor_position / maxColumns)); } }
void Initialize(CHotSpot oHotSpot, bool bMiddleClickOp) { _oHotSpot = oHotSpot; _bMiddleClickOp = bMiddleClickOp; _eEditMode = CGame.INSTANCE._oCursor._EditMode; // Our gizmo mode is the mode of the cursor edit mode at startup. gameObject.name = "Gizmo-" + _eEditMode.ToString(); //=== Set the initializing gizmo the position and rotation of the hotspot. We have to move/rotate both at every frame === transform.parent = null; // Note that we are NOT a child of our owning hotspot... transform.position = _oHotSpot.transform.position; if (_eEditMode != EEditMode.Move) // Only start at the object's current location if we're rotate or scale. we always move with axis-aliged gizmo transform.rotation = _oHotSpot.transform.rotation; transform.localScale = new Vector3(CCursor.C_GizmoScale, CCursor.C_GizmoScale, CCursor.C_GizmoScale); // Gizmo is always drawn at the default scale regardless of hotspot scaling. if (_eEditMode == EEditMode.Rotate) // Magnify the rotation cursor a given ratio as it frequently needs a bigger size for easy user manipulation transform.localScale *= CCursor.C_GizmoScale_RotationMultiplier; //=== Handling of special 'hidden helper object' mode = Hide gizmo and immediately begin move opeation along y,z axis === if (CGame.INSTANCE._bGameModeBasicInteractions) { Renderer[] aRend = transform.GetComponentsInChildren<Renderer>(); //###IMPROVE? Instead of hiding all gizmo elements, would it be too tough to just not instantiate its prefab?? foreach (Renderer oRend in aRend) oRend.enabled = false; _eModeGizmo = EModeGizmo.S2_UserDraggingGizmoPart; // Direct fast-track to immediately drag gizmo... GizmoTransform_Begin(true); // ... by forcing a move operation on YZ plane } else { _eModeGizmo = EModeGizmo.S1_WaitingLeftClickGizmoPart; } }
public void drawEdit(int positionId, string prompt, string caption, int cursor_position, bool selected, EEditMode mode) { drawLink(positionId, prompt + caption, EAlignment.justify_left); if (selected) { switch (mode) { case EEditMode.alphanum_high: drawText(maxColumns - 3, 0, "ABC"); break; case EEditMode.alphanum_low: drawText(maxColumns - 3, 0, "abc"); break; case EEditMode.numeric: drawText(maxColumns - 3, 0, "123"); break; } } if (selected) formSetCursor(prompt.Length + cursor_position, positionId); }
public override bool HandleInput(SKeyEvent keyEvent) { if (_EditMode == EEditMode.None) { base.HandleInput(keyEvent); } if (keyEvent.KeyPressed && !Char.IsControl(keyEvent.Unicode)) { switch (_EditMode) { case EEditMode.None: break; case EEditMode.PlayerName: _SelectSlides[_SelectSlideProfiles].RenameValue( CProfiles.AddGetPlayerName(_SelectSlides[_SelectSlideProfiles].SelectedTag, keyEvent.Unicode)); _ProfilesChanged = true; break; } } else { switch (keyEvent.Key) { case Keys.Escape: if (_EditMode == EEditMode.PlayerName) { _EditMode = EEditMode.None; } else { CGraphics.FadeTo(EScreen.Main); } break; case Keys.Enter: if (_Buttons[_ButtonExit].Selected) { CGraphics.FadeTo(EScreen.Main); } else if (_Buttons[_ButtonSave].Selected) { _SaveProfiles(); } else if (_Buttons[_ButtonNew].Selected) { _NewProfile(); } else if (_Buttons[_ButtonPlayerName].Selected) { if (CProfiles.NumProfiles > 0 && _EditMode != EEditMode.PlayerName) { _EditMode = EEditMode.PlayerName; } else { _EditMode = EEditMode.None; } } else if (_Buttons[_ButtonDelete].Selected) { _DeleteProfile(); } else if (_Buttons[_ButtonWebcam].Selected) { _OnWebcam(); } else if (_Buttons[_ButtonSaveSnapshot].Selected) { _OnSaveSnapshot(); } else if (_Buttons[_ButtonDiscardSnapshot].Selected) { _OnDiscardSnapshot(); } else if (_Buttons[_ButtonTakeSnapshot].Selected) { _OnTakeSnapshot(); } break; case Keys.Back: if (_EditMode == EEditMode.PlayerName) { _SelectSlides[_SelectSlideProfiles].RenameValue( CProfiles.GetDeleteCharInPlayerName(_SelectSlides[_SelectSlideProfiles].SelectedTag)); _ProfilesChanged = true; } else { CGraphics.FadeTo(EScreen.Main); } break; case Keys.Delete: _DeleteProfile(); break; } if (_SelectSlides[_SelectSlideDifficulty].Selected) { CProfiles.SetDifficulty(_SelectSlides[_SelectSlideProfiles].SelectedTag, (EGameDifficulty)_SelectSlides[_SelectSlideDifficulty].Selection); } else if (_SelectSlides[_SelectSlideAvatars].Selected) { CProfiles.SetAvatar(_SelectSlides[_SelectSlideProfiles].SelectedTag, _SelectSlides[_SelectSlideAvatars].SelectedTag); } else if (_SelectSlides[_SelectSlideUserRole].Selected) { CProfiles.SetUserRoleProfile(_SelectSlides[_SelectSlideProfiles].SelectedTag, (EUserRole)_SelectSlides[_SelectSlideUserRole].Selection); } else if (_SelectSlides[_SelectSlideActive].Selected) { CProfiles.SetActive(_SelectSlides[_SelectSlideProfiles].SelectedTag, (EOffOn)_SelectSlides[_SelectSlideActive].Selection); } } return(true); }
public override void OnClose() { base.OnClose(); _EditMode = EEditMode.None; }
void OnGUI() { if (Application.isPlaying) { EditorGUILayout.LabelField("Please exit the play mode."); return; } if (mTilemap == null) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Level"); mMapLevel = (uint)EditorGUILayout.IntField((int)mMapLevel); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("TileMap Width:"); var width = (uint)EditorGUILayout.IntField(11); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("TileMap Height"); var height = (uint)EditorGUILayout.IntField(11); EditorGUILayout.EndHorizontal(); if (GUILayout.Button("Generate TileMap")) { var tile_map_obj = new GameObject("TileMap"); mTilemap = tile_map_obj.AddComponent <EditorData.TileMap>(); tile_map_obj.tag = "TileMap"; mTilemap.Level = mMapLevel; mTilemap.Init(width, height); } if (GUILayout.Button("Load TileMap")) { var asset = Resources.Load("level" + mMapLevel) as TextAsset; Data.TileMapData tile_map_data = null; using (var stream = new MemoryStream(asset.bytes)) { var formatter = new BinaryFormatter(); tile_map_data = formatter.Deserialize(stream) as Data.TileMapData; } //var tile_map_data = AssetDatabase.LoadAssetAtPath("Assets/test.asset", typeof(Data.TileMapData)) as Data.TileMapData; var tile_map_obj = new GameObject("TileMap"); mTilemap = tile_map_obj.AddComponent <EditorData.TileMap>(); tile_map_obj.tag = "TileMap"; mTilemap.Level = tile_map_data.Level; mTilemap.Init(tile_map_data.Width, tile_map_data.Height); var floor_layer = tile_map_data.FloorLayer; for (int r = 0; r < floor_layer.GetLength(0); ++r) { for (int c = 0; c < floor_layer.GetLength(1); ++c) { var tile = TerrainList.CreateTile((Logic.Tile.EType)floor_layer[r, c]); mTilemap.SetTile(r, c, tile, ETileMapLayer.Floor); } } foreach (var monster_data in tile_map_data.MonsterDatas) { var monster = MonsterList.CreateTile(monster_data.Id); mTilemap.SetTile((int)monster_data.Pos.Row, (int)monster_data.Pos.Col, monster, ETileMapLayer.Collide); } foreach (var portal_data in tile_map_data.PortalDatas) { var portal = PortalList.CreateTile(portal_data.PortalType, portal_data.DestinationLevel, portal_data.DestinationPosition); mTilemap.SetTile((int)portal_data.Pos.Row, (int)portal_data.Pos.Col, portal, ETileMapLayer.Collide); } } return; } EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Level"); mTilemap.Level = (uint)EditorGUILayout.IntField((int)mTilemap.Level); EditorGUILayout.EndHorizontal(); mEditMode = (EEditMode)EditorGUILayout.EnumPopup("Edit Mode", mEditMode); if (mEditMode == EEditMode.Modify || mEditMode == EEditMode.Erase) { mEditRange = EditorGUILayout.IntSlider("Range", mEditRange, 1, 4); } mEditLayer = (ETileMapLayer)EditorGUILayout.EnumPopup("Edit Layer", mEditLayer); EditorGUILayout.LabelField("Terrain List", EditorStyles.boldLabel); if (mTerrainList.Draw()) { Repaint(); } EditorGUILayout.LabelField("Portal List", EditorStyles.boldLabel); if (mPortalList.Draw()) { Repaint(); } EditorGUILayout.LabelField("Monster List", EditorStyles.boldLabel); if (mMonsterList.Draw()) { Repaint(); } EditorGUILayout.LabelField("Item List", EditorStyles.boldLabel); if (mItemList.Draw()) { Repaint(); } if (GUILayout.Button("Save")) { mTilemap.Save(string.Format("Assets/Resources/level{0}.bytes", mTilemap.Level)); } }
public override bool HandleInput(KeyEvent KeyEvent) { if (_EditMode == EEditMode.None) { base.HandleInput(KeyEvent); } if (KeyEvent.KeyPressed && !Char.IsControl(KeyEvent.Unicode)) { switch (_EditMode) { case EEditMode.None: break; case EEditMode.PlayerName: SelectSlides[htSelectSlides(SelectSlideProfiles)].RenameValue( CProfiles.AddGetPlayerName(SelectSlides[htSelectSlides(SelectSlideProfiles)].Selection, KeyEvent.Unicode)); break; default: break; } } else { switch (KeyEvent.Key) { case Keys.Escape: CGraphics.FadeTo(EScreens.ScreenMain); break; case Keys.Enter: if (Buttons[htButtons(ButtonExit)].Selected) { CGraphics.FadeTo(EScreens.ScreenMain); } else if (Buttons[htButtons(ButtonSave)].Selected) { SaveProfiles(); } else if (Buttons[htButtons(ButtonNew)].Selected) { NewProfile(); } else if (Buttons[htButtons(ButtonPlayerName)].Selected) { if (CProfiles.NumProfiles > 0 && _EditMode != EEditMode.PlayerName) { _EditMode = EEditMode.PlayerName; } else { _EditMode = EEditMode.None; } } else if (Buttons[htButtons(ButtonDelete)].Selected) { DeleteProfile(); } break; case Keys.Back: if (_EditMode == EEditMode.PlayerName) { SelectSlides[htSelectSlides(SelectSlideProfiles)].RenameValue( CProfiles.GetDeleteCharInPlayerName(SelectSlides[htSelectSlides(SelectSlideProfiles)].Selection)); } else { CGraphics.FadeTo(EScreens.ScreenMain); } break; case Keys.Delete: DeleteProfile(); break; } if (SelectSlides[htSelectSlides(SelectSlideDifficulty)].Selected) { CProfiles.SetDifficulty(SelectSlides[htSelectSlides(SelectSlideProfiles)].Selection, (EGameDifficulty)SelectSlides[htSelectSlides(SelectSlideDifficulty)].Selection); } else if (SelectSlides[htSelectSlides(SelectSlideAvatars)].Selected) { CProfiles.SetAvatar(SelectSlides[htSelectSlides(SelectSlideProfiles)].Selection, SelectSlides[htSelectSlides(SelectSlideAvatars)].Selection); } else if (SelectSlides[htSelectSlides(SelectSlideGuestProfile)].Selected) { CProfiles.SetGuestProfile(SelectSlides[htSelectSlides(SelectSlideProfiles)].Selection, (EOffOn)SelectSlides[htSelectSlides(SelectSlideGuestProfile)].Selection); } else if (SelectSlides[htSelectSlides(SelectSlideActive)].Selected) { CProfiles.SetActive(SelectSlides[htSelectSlides(SelectSlideProfiles)].Selection, (EOffOn)SelectSlides[htSelectSlides(SelectSlideActive)].Selection); } } return(true); }
public void changeEditMode(EEditMode eEditMode) { this.eEditMode = eEditMode; }
protected override void OnMouseDown(MouseEventArgs e) { if (EditMode == EEditMode.Pan) { dragging = true; dragStartPoint = e.Location; } else if (EditMode == EEditMode.TransformTexture) { Point p = e.Location; Rectangle r = animTexture.GetAABB(); Rectangle camR = camera.RectangleToScreen(r); transType = TransHelper.CheckTransformRect(camR, p); if (transType != ETransformType.None) { dragStartPoint = p; dragging = true; } else { EditMode = EEditMode.Idle; } } else if (EditMode == EEditMode.TransformBody) { Point p = e.Location; Rectangle r = physicsBody.GetAABB(); Rectangle camR = camera.RectangleToScreen(r); transType = TransHelper.CheckTransformRect(camR, p); if (transType != ETransformType.None) { dragStartPoint = p; dragging = true; } else { EditMode = EEditMode.Idle; } } }
public CEditMode(EEditMode mode, CCBTreeViewItem node) { EditMode = mode; Node = node; }
protected override void OnMouseDown(MouseEventArgs e) { if (EditMode == EEditMode.Pan) { dragging = true; dragStartPoint = e.Location; } else if (EditMode == EEditMode.Transform) { Point p = e.Location; Rectangle r = (CurrentItem.GetCompByType(typeof(Transform)) as Transform).GetOrthoBox(); Rectangle camR = camera.RectangleToScreen(r); transType = TransHelper.CheckTransformRect(camR, p); if (transType != ETransformType.None) { dragStartPoint = p; dragging = true; } else { EditMode = EEditMode.Idle; } } }
public override bool HandleMouse(SMouseEvent mouseEvent) { if (_EditMode == EEditMode.None) { base.HandleMouse(mouseEvent); } if (mouseEvent.LB && _IsMouseOverCurSelection(mouseEvent)) { if (_Buttons[_ButtonCancel].Selected) { _DeleteProfile(); _ClosePopup(); } else if (_Buttons[_ButtonSave].Selected) { _SaveProfiles(); _ClosePopup(); } /*else if (_Buttons[_ButtonNew].Selected) * _NewProfile(); * else if (_Buttons[_ButtonDelete].Selected) * _DeleteProfile();*/ else if (_Buttons[_ButtonPlayerName].Selected) { if (CProfiles.NumProfiles > 0 && _EditMode != EEditMode.PlayerName) { _EditMode = EEditMode.PlayerName; } else { _EditMode = EEditMode.None; } } else if (_SelectSlides[_SelectSlideDifficulty].Selected) { CProfiles.SetDifficulty(_NewProfileID, (EGameDifficulty)_SelectSlides[_SelectSlideDifficulty].Selection); } else if (_SelectSlides[_SelectSlideAvatars].Selected) { CProfiles.SetAvatar(_NewProfileID, _SelectSlides[_SelectSlideAvatars].SelectedTag); } /*else if (_SelectSlides[_SelectSlideUserRole].Selected) * { * CProfiles.SetUserRoleProfile(_NewProfileID, * (EUserRole)_SelectSlides[_SelectSlideUserRole].Selection); * } * else if (_SelectSlides[_SelectSlideActive].Selected) * { * CProfiles.SetActive(_NewProfileID, * (EOffOn)_SelectSlides[_SelectSlideActive].Selection); * } */ } if (mouseEvent.RB) { _ClosePopup(); } return(true); }
public override bool UpdateGame() { if (_Buttons[_ButtonPlayerName].Selected) { _EditMode = EEditMode.PlayerName; } //BODGE! for (int i = 0; i < 3; i++) { _Texts["TextSelectSlideDifficulty" + i].Text = _SelectSlides[_SelectSlideDifficulty].SelectedValue; _Statics["StaticSelectSlideDifficultyL" + i].Visible = true; _Statics["StaticSelectSlideDifficultyR" + i].Visible = true; if (_SelectSlides[_SelectSlideDifficulty].Selection == 0) { _Statics["StaticSelectSlideDifficultyL" + i].Visible = false; } if (_SelectSlides[_SelectSlideDifficulty].Selection == _SelectSlides[_SelectSlideDifficulty].NumValues - 1) { _Statics["StaticSelectSlideDifficultyR" + i].Visible = false; } _Texts["TextSelectSlideAvatars" + i].Text = _SelectSlides[_SelectSlideAvatars].SelectedValue; _Statics["StaticSelectSlideAvatarsL" + i].Visible = true; _Statics["StaticSelectSlideAvatarsR" + i].Visible = true; if (_SelectSlides[_SelectSlideAvatars].Selection == 0) { _Statics["StaticSelectSlideAvatarsL" + i].Visible = false; } if (_SelectSlides[_SelectSlideAvatars].Selection == _SelectSlides[_SelectSlideAvatars].NumValues - 1) { _Statics["StaticSelectSlideAvatarsR" + i].Visible = false; } _Statics["StaticAvatar" + i].Aspect = _Statics["StaticAvatar"].Aspect; _Statics["StaticAvatar" + i].Texture = _Statics["StaticAvatar"].Texture; _Texts["TextPlayerName" + i].Text = _Buttons[_ButtonPlayerName].Text.Text; if (_Buttons[_ButtonPlayerName].Selected) { _Statics[_StaticButtonPlayerName[i]].Visible = true; _Statics[_StaticButtonPlayerName[i]].Texture = _Buttons[_ButtonPlayerName].SelTexture; _Statics[_StaticButtonPlayerName[i]].Color = _Buttons[_ButtonPlayerName].SelColor; } else { _Statics[_StaticButtonPlayerName[i]].Visible = false; } if (_Buttons[_ButtonCancel].Selected) { _Statics["StaticButtonCancel" + i].Color = _Buttons[_ButtonCancel].SelColor; _Texts["TextButtonCancel" + i].Selected = true; } else { _Statics["StaticButtonCancel" + i].Color = _Buttons[_ButtonCancel].Color; _Texts["TextButtonCancel" + i].Selected = false; } if (_Buttons[_ButtonSave].Selected) { _Statics["StaticButtonSave" + i].Color = _Buttons[_ButtonSave].SelColor; _Texts["TextButtonSave" + i].Selected = true; } else { _Statics["StaticButtonSave" + i].Color = _Buttons[_ButtonSave].Color; _Texts["TextButtonSave" + i].Selected = false; } if (_SelectSlides[_SelectSlideDifficulty].Selected) { _Statics["StaticSelectSlideDifficulty" + i].Visible = true; _Texts["TextSelectSlideDifficulty" + i].Selected = true; } else { _Statics["StaticSelectSlideDifficulty" + i].Visible = false; _Texts["TextSelectSlideDifficulty" + i].Selected = false; } if (_SelectSlides[_SelectSlideAvatars].Selected) { _Statics["StaticSelectSlideAvatars" + i].Visible = true; _Texts["TextSelectSlideAvatars" + i].Selected = true; } else { _Statics["StaticSelectSlideAvatars" + i].Visible = false; _Texts["TextSelectSlideAvatars" + i].Selected = false; } } if (_AvatarsChanged) { _LoadAvatars(true); } if (_ProfilesChanged) { _LoadProfiles(true); } //if (_SelectSlides[_SelectSlideProfiles].Selection > -1) //{ _Buttons[_ButtonPlayerName].Text.Text = CProfiles.GetPlayerName(_NewProfileID); if (_EditMode == EEditMode.PlayerName && _CursorBlink) { _Buttons[_ButtonPlayerName].Text.Text = " " + _Buttons[_ButtonPlayerName].Text.Text + "_"; } else { _Buttons[_ButtonPlayerName].Text.Text = " " + _Buttons[_ButtonPlayerName].Text.Text + " "; } _SelectSlides[_SelectSlideDifficulty].Selection = (int)CProfiles.GetDifficulty(_NewProfileID); //_SelectSlides[_SelectSlideUserRole].Selection = (int)CProfiles.GetUserRoleProfile(_NewProfileID); //_SelectSlides[_SelectSlideActive].Selection = (int)CProfiles.GetActive(_NewProfileID); int avatarID = CProfiles.GetAvatarID(_NewProfileID); _SelectSlides[_SelectSlideAvatars].SelectedTag = avatarID; _Statics[_StaticAvatar].Texture = CProfiles.GetAvatarTexture(avatarID); //} return(true); }
private void _SaveProfiles() { _EditMode = EEditMode.None; CProfiles.SaveProfiles(); }
public override bool HandleMouse(MouseEvent MouseEvent) { if (_EditMode == EEditMode.None) { base.HandleMouse(MouseEvent); } if (MouseEvent.LB && IsMouseOver(MouseEvent)) { if (Buttons[htButtons(ButtonExit)].Selected) { CGraphics.FadeTo(EScreens.ScreenMain); } else if (Buttons[htButtons(ButtonSave)].Selected) { SaveProfiles(); } else if (Buttons[htButtons(ButtonNew)].Selected) { NewProfile(); } else if (Buttons[htButtons(ButtonDelete)].Selected) { DeleteProfile(); } else if (Buttons[htButtons(ButtonPlayerName)].Selected) { if (CProfiles.NumProfiles > 0 && _EditMode != EEditMode.PlayerName) { _EditMode = EEditMode.PlayerName; } else { _EditMode = EEditMode.None; } } else if (SelectSlides[htSelectSlides(SelectSlideDifficulty)].Selected) { CProfiles.SetDifficulty(SelectSlides[htSelectSlides(SelectSlideProfiles)].Selection, (EGameDifficulty)SelectSlides[htSelectSlides(SelectSlideDifficulty)].Selection); } else if (SelectSlides[htSelectSlides(SelectSlideAvatars)].Selected) { CProfiles.SetAvatar(SelectSlides[htSelectSlides(SelectSlideProfiles)].Selection, SelectSlides[htSelectSlides(SelectSlideAvatars)].Selection); } else if (SelectSlides[htSelectSlides(SelectSlideGuestProfile)].Selected) { CProfiles.SetGuestProfile(SelectSlides[htSelectSlides(SelectSlideProfiles)].Selection, (EOffOn)SelectSlides[htSelectSlides(SelectSlideGuestProfile)].Selection); } else if (SelectSlides[htSelectSlides(SelectSlideActive)].Selected) { CProfiles.SetActive(SelectSlides[htSelectSlides(SelectSlideProfiles)].Selection, (EOffOn)SelectSlides[htSelectSlides(SelectSlideActive)].Selection); } } if (MouseEvent.RB) { CGraphics.FadeTo(EScreens.ScreenMain); } return(true); }
private void _DeleteProfile() { _EditMode = EEditMode.None; CProfiles.DeleteProfile(_NewProfileID); }
public override bool HandleInput(KeyEvent KeyEvent) { if (_EditMode == EEditMode.None) base.HandleInput(KeyEvent); if (KeyEvent.KeyPressed && !Char.IsControl(KeyEvent.Unicode)) { switch (_EditMode) { case EEditMode.None: break; case EEditMode.PlayerName: SelectSlides[htSelectSlides(SelectSlideProfiles)].RenameValue( CProfiles.AddGetPlayerName(SelectSlides[htSelectSlides(SelectSlideProfiles)].Selection, KeyEvent.Unicode)); break; default: break; } } else { switch (KeyEvent.Key) { case Keys.Escape: CGraphics.FadeTo(EScreens.ScreenMain); break; case Keys.Enter: if (Buttons[htButtons(ButtonExit)].Selected) { CGraphics.FadeTo(EScreens.ScreenMain); } else if (Buttons[htButtons(ButtonSave)].Selected) { SaveProfiles(); } else if (Buttons[htButtons(ButtonNew)].Selected) { NewProfile(); } else if (Buttons[htButtons(ButtonPlayerName)].Selected) { if (CProfiles.NumProfiles > 0 && _EditMode != EEditMode.PlayerName) _EditMode = EEditMode.PlayerName; else _EditMode = EEditMode.None; } else if (Buttons[htButtons(ButtonDelete)].Selected) { DeleteProfile(); } else if (Buttons[htButtons(ButtonWebcam)].Selected && CWebcam.GetDevices().Length > 0) { OnWebcam(); } else if (Buttons[htButtons(ButtonSaveSnapshot)].Selected && CWebcam.GetDevices().Length > 0) { OnSaveSnapshot(); } else if (Buttons[htButtons(ButtonDiscardSnapshot)].Selected && CWebcam.GetDevices().Length > 0) { OnDiscardSnapshot(); } else if (Buttons[htButtons(ButtonTakeSnapshot)].Selected && CWebcam.GetDevices().Length > 0) { OnTakeSnapshot(); } break; case Keys.Back: if (_EditMode == EEditMode.PlayerName) { SelectSlides[htSelectSlides(SelectSlideProfiles)].RenameValue( CProfiles.GetDeleteCharInPlayerName(SelectSlides[htSelectSlides(SelectSlideProfiles)].Selection)); } else CGraphics.FadeTo(EScreens.ScreenMain); break; case Keys.Delete: DeleteProfile(); break; } if (SelectSlides[htSelectSlides(SelectSlideDifficulty)].Selected) { CProfiles.SetDifficulty(SelectSlides[htSelectSlides(SelectSlideProfiles)].Selection, (EGameDifficulty)SelectSlides[htSelectSlides(SelectSlideDifficulty)].Selection); } else if (SelectSlides[htSelectSlides(SelectSlideAvatars)].Selected) { CProfiles.SetAvatar(SelectSlides[htSelectSlides(SelectSlideProfiles)].Selection, SelectSlides[htSelectSlides(SelectSlideAvatars)].Selection); } else if (SelectSlides[htSelectSlides(SelectSlideGuestProfile)].Selected) { CProfiles.SetGuestProfile(SelectSlides[htSelectSlides(SelectSlideProfiles)].Selection, (EOffOn)SelectSlides[htSelectSlides(SelectSlideGuestProfile)].Selection); } else if (SelectSlides[htSelectSlides(SelectSlideActive)].Selected) { CProfiles.SetActive(SelectSlides[htSelectSlides(SelectSlideProfiles)].Selection, (EOffOn)SelectSlides[htSelectSlides(SelectSlideActive)].Selection); } } return true; }
public override bool HandleInput(SKeyEvent keyEvent) { if ((keyEvent.Key == Keys.Up || keyEvent.Key == Keys.Down) && _EditMode == EEditMode.PlayerName) { _EditMode = EEditMode.None; } if (_EditMode == EEditMode.None) { base.HandleInput(keyEvent); } if (keyEvent.KeyPressed && !Char.IsControl(keyEvent.Unicode)) { switch (_EditMode) { case EEditMode.None: break; case EEditMode.PlayerName: CProfiles.AddGetPlayerName(_NewProfileID, keyEvent.Unicode); _ProfilesChanged = true; break; } } else { switch (keyEvent.Key) { case Keys.Escape: _DeleteProfile(); _ClosePopup(); break; case Keys.Enter: if (_Buttons[_ButtonCancel].Selected) { _DeleteProfile(); _ClosePopup(); } else if (_Buttons[_ButtonSave].Selected) { _SaveProfiles(); _ClosePopup(); } /*else if (_Buttons[_ButtonNew].Selected) * _NewProfile();*/ else if (_Buttons[_ButtonPlayerName].Selected) { if (CProfiles.NumProfiles > 0 && _EditMode != EEditMode.PlayerName) { _EditMode = EEditMode.PlayerName; } else { _EditMode = EEditMode.None; } } /*else if (_Buttons[_ButtonDelete].Selected) * _DeleteProfile();*/ break; case Keys.Back: if (_EditMode == EEditMode.PlayerName) { CProfiles.GetDeleteCharInPlayerName(_NewProfileID); _ProfilesChanged = true; } else { _ClosePopup(); } break; case Keys.Delete: _DeleteProfile(); break; } if (_SelectSlides[_SelectSlideDifficulty].Selected) { CProfiles.SetDifficulty(_NewProfileID, (EGameDifficulty)_SelectSlides[_SelectSlideDifficulty].Selection); } else if (_SelectSlides[_SelectSlideAvatars].Selected) { CProfiles.SetAvatar(_NewProfileID, _SelectSlides[_SelectSlideAvatars].SelectedTag); } /*else if (_SelectSlides[_SelectSlideUserRole].Selected) * { * CProfiles.SetUserRoleProfile(_NewProfileID, * (EUserRole)_SelectSlides[_SelectSlideUserRole].Selection); * } * else if (_SelectSlides[_SelectSlideActive].Selected) * { * CProfiles.SetActive(_NewProfileID, * (EOffOn)_SelectSlides[_SelectSlideActive].Selection); * }*/ } return(true); }
public override void OnHotspotChanged(CGizmo oGizmo, EEditMode eEditMode, EHotSpotOp eHotSpotOp) { if (eEditMode != EEditMode.Move) //###DESIGN!!!!: Can rotate? return; base.OnHotspotChanged(oGizmo, eEditMode, eHotSpotOp); // Will set our position, properties and script record. Vector3 vecPosHotspotG = oGizmo.transform.position; Vector3 vecPosHotspotL = transform.parent.worldToLocalMatrix.MultiplyPoint(vecPosHotspotG); // Convert the global hotspot position to the position relative to our parent (ActorEmpty) (Done so our animation is stored relative to our parent so user can drag parent while animating) if (oGizmo._bMiddleClickOp) { // Left mouse button editing moves sex, middle mouse button animates switch (eHotSpotOp) { case EHotSpotOp.First: _oCurveAnimY = new AnimationCurve(); // Create the animation curves to store the (independant) Y & Z coordinates _oCurveAnimZ = new AnimationCurve(); _nAnimStartRec = Time.time; // Store the time of clip recording so we can determine clip length for 0-based curves. _vecPosStart = _vecPosLast = vecPosHotspotL; _nDistTravelled = 0; CGame.INSTANCE._nAnimMult_Pos = 1; //###CHECK CGame.INSTANCE._nAnimMult_Time = 1; _eAnimMode = EAnimMode.Record; break; case EHotSpotOp.Middle: float nAnimTime = Time.time - _nAnimStartRec; Vector3 vecPosFromStart = vecPosHotspotL - _vecPosStart; _oCurveAnimY.AddKey(nAnimTime, vecPosFromStart.y); _oCurveAnimZ.AddKey(nAnimTime, vecPosFromStart.z); _nDistTravelled += (vecPosHotspotL - _vecPosLast).magnitude; // Add the distance travelled this last frame _vecPosLast = vecPosHotspotL; // Remember where we are now for next distance travelled adder //CGame.INSTANCE._sGuiString_Dev_DEBUG = string.Format("Rec {0:F1} Dist: {1:F2}", nAnimTime, _nDistTravelled); break; case EHotSpotOp.Last: // End recording by adding one last data point to return to start position at an appropriately calculated time. _nAnimStartPlay = Time.time; _nAnimClipLength = _nAnimStartPlay - _nAnimStartRec; _nAnimStartRec = 0; float nVelocityAvg = _nDistTravelled / _nAnimClipLength; // The average velocity of travel for this curve float nDistStartPtToEndPt = (vecPosHotspotL - _vecPosStart).magnitude; // The distance between the start and end point we must travel to to close the loop float nTimeToReturnToStartPt = nDistStartPtToEndPt / nVelocityAvg; // The time needed to return to starting point at average velocity _nAnimStartPlay = Time.time - _nAnimClipLength; // Set the current pointer to play to where we are at now in the curve. (This will make us return to starting point smoothly) _nAnimClipLength += nTimeToReturnToStartPt; // Add the time to travel to the last point to the total clip time. _oCurveAnimY.AddKey(_nAnimClipLength, 0); // Add the starting point position at the end-of-clip time. _oCurveAnimZ.AddKey(_nAnimClipLength, 0); //=== Find the other body (if it exists) and slow-down or speed up our clip if our clip time is nearby the cliptime of the other body //###BROKEN#11 //CBody oBodyOther = null; //foreach (CBody oBody in CGame.INSTANCE._aBodyBases) { // if (oBody != _oBody) { // oBodyOther = oBody; // break; // } //} //if (oBodyOther != null && oBodyOther._oActor_Pelvis != null) { // If another body with a sex actor exists... // if ((_nAnimClipLength <= oBodyOther._oActor_Pelvis._nAnimClipLength * 1.2f) && (_nAnimClipLength >= oBodyOther._oActor_Pelvis._nAnimClipLength * 0.8f)) { //... and has nearly the same lenght as ours... ###TUNE // oBodyOther._oActor_Pelvis._nTimeRatioToMatchOtherBody = oBodyOther._oActor_Pelvis._nAnimClipLength / _nAnimClipLength; // We set the other body's time because we could be facing a long return to first position as inserted above // //Debug.Log("Anim: _nTimeRatioToMatchOtherBody = " + oBodyOther._oActor_Pelvis._nTimeRatioToMatchOtherBody); // } //} _nTimeRatioToMatchOtherBody = 1; //CGame.INSTANCE._sGuiString_Dev_DEBUG = ""; _eAnimMode = EAnimMode.Play; break; } } else { _eAnimMode = EAnimMode.Stopped; // If user moves with left mouse button we stop previously recorded animation } }
public void drawEditBox(int posY, int lines, string prompt, string captionOrg, int cursor_position, bool selected, EEditMode mode) { string caption = prompt + captionOrg; drawTextBox(posY, lines, caption, EAlignment.justify_left); if (selected) { switch (mode) { case EEditMode.alphanum_high: drawText(maxColumns - 3, 0, "ABC"); break; case EEditMode.alphanum_low: drawText(maxColumns - 3, 0, "abc"); break; case EEditMode.numeric: drawText(maxColumns - 3, 0, "123"); break; } } if (selected) formSetCursor(prompt.Length + cursor_position % maxColumns, posY + (cursor_position/maxColumns)); }
public bool HandleInput(KeyEvent KeyEvent) { if (Selected) { //Active EditMode ignores other input! if (_EditMode == EEditMode.PlaylistName) { if (KeyEvent.KeyPressed && !Char.IsControl(KeyEvent.Unicode)) { _Theme.ButtonPlaylistName.Text.Text = _Theme.ButtonPlaylistName.Text.Text + KeyEvent.Unicode; } else if (KeyEvent.Key == Keys.Enter) { CPlaylists.Playlists[ActivePlaylistID].PlaylistName = _Theme.ButtonPlaylistName.Text.Text; CPlaylists.Playlists[ActivePlaylistID].SavePlaylist(); _EditMode = EEditMode.None; _Theme.ButtonPlaylistName.EditMode = false; } else if (KeyEvent.Key == Keys.Escape) { _Theme.ButtonPlaylistName.Text.Text = CPlaylists.Playlists[ActivePlaylistID].PlaylistName; _EditMode = EEditMode.None; _Theme.ButtonPlaylistName.EditMode = false; } else if (KeyEvent.Key == Keys.Back || KeyEvent.Key == Keys.Delete) { if (_Theme.ButtonPlaylistName.Text.Text.Length > 0) _Theme.ButtonPlaylistName.Text.Text = _Theme.ButtonPlaylistName.Text.Text.Remove(_Theme.ButtonPlaylistName.Text.Text.Length - 1); } } else { if (CurrentPlaylistElement == -1 || PlaylistElementContents.Count == 0) //no song is selected { _Interactions.HandleInput(KeyEvent); CurrentPlaylistElement = GetSelectedSelectionNr(); if (CurrentPlaylistElement != -1) return true; } else if (CurrentPlaylistElement != -1) //a song is selected { int ScrollLimit = PlaylistElements.Count / 2; //special actions if a song is selected switch (KeyEvent.Key) { case Keys.Up: if (KeyEvent.ModSHIFT) { _Interactions.SetInteractionToSelectSlide(PlaylistElements[0].SelectSlide); _Interactions.HandleInput(KeyEvent); CurrentPlaylistElement = GetSelectedSelectionNr(); } else if (CurrentPlaylistElement > ScrollLimit || PlaylistElementContents.Count == 0) { _Interactions.HandleInput(KeyEvent); CurrentPlaylistElement = GetSelectedSelectionNr(); } else if (CurrentPlaylistElement <= ScrollLimit) { if (Offset > 0) { Offset--; Update(); } else { _Interactions.HandleInput(KeyEvent); CurrentPlaylistElement = GetSelectedSelectionNr(); } } break; case Keys.Down: if (KeyEvent.ModSHIFT) { for (int i = PlaylistElements.Count - 1; i >= 0; i--) { if (PlaylistElements[i].SelectSlide.Visible) { _Interactions.SetInteractionToSelectSlide(PlaylistElements[0].SelectSlide); _Interactions.HandleInput(KeyEvent); CurrentPlaylistElement = GetSelectedSelectionNr(); } } } else if (CurrentPlaylistElement >= ScrollLimit) { if (Offset < PlaylistElementContents.Count - PlaylistElements.Count) { Offset++; Update(); } else { _Interactions.HandleInput(KeyEvent); CurrentPlaylistElement = GetSelectedSelectionNr(); } } else if (CurrentPlaylistElement < ScrollLimit) { _Interactions.HandleInput(KeyEvent); CurrentPlaylistElement = GetSelectedSelectionNr(); } break; case Keys.Delete: CPlaylists.Playlists[ActivePlaylistID].DeleteSong(PlaylistElements[CurrentPlaylistElement].Content); UpdatePlaylist(); if (Offset > 0) Offset--; Update(); if (PlaylistElementContents.Count - 1 < CurrentPlaylistElement) { CurrentPlaylistElement = PlaylistElementContents.Count - 1; } if (CurrentPlaylistElement != -1) _Interactions.SetInteractionToSelectSlide(PlaylistElements[CurrentPlaylistElement].SelectSlide); break; case Keys.Back: ClosePlaylist(); //really? or better global? break; case Keys.Enter: StartPlaylistSongs(); break; case Keys.Add: //move the selected song up if (PlaylistElementContents.Count > 1 && (CurrentPlaylistElement > 0 || Offset > 0)) { CPlaylists.Playlists[ActivePlaylistID].SongUp(CurrentPlaylistElement + Offset); UpdatePlaylist(); KeyEvent key = new KeyEvent(); key.Key = Keys.Up; if (CurrentPlaylistElement > ScrollLimit) { _Interactions.HandleInput(key); CurrentPlaylistElement = GetSelectedSelectionNr(); } else if (CurrentPlaylistElement <= ScrollLimit) { if (Offset > 0) { Offset--; Update(); } else { _Interactions.HandleInput(key); CurrentPlaylistElement = GetSelectedSelectionNr(); } } } break; case Keys.Subtract: //move the selected song down if (PlaylistElementContents.Count > 1 && CurrentPlaylistElement + Offset < PlaylistElementContents.Count - 1) { CPlaylists.Playlists[ActivePlaylistID].SongDown(CurrentPlaylistElement + Offset); UpdatePlaylist(); KeyEvent key = new KeyEvent(); key.Key = Keys.Down; if (CurrentPlaylistElement >= ScrollLimit) { if (Offset < PlaylistElementContents.Count - PlaylistElements.Count) { Offset++; Update(); } else { _Interactions.HandleInput(key); CurrentPlaylistElement = GetSelectedSelectionNr(); } } else if (CurrentPlaylistElement < ScrollLimit) { _Interactions.HandleInput(key); CurrentPlaylistElement = GetSelectedSelectionNr(); } } break; case Keys.PageUp: //scroll up if (PlaylistElementContents.Count > 0) { Offset -= PlaylistElements.Count; if (Offset < 0) Offset = 0; Update(); CurrentPlaylistElement = 0; } break; case Keys.PageDown: //scroll down if (PlaylistElementContents.Count > 0) { Offset += PlaylistElements.Count; if (Offset > PlaylistElementContents.Count - PlaylistElements.Count) Offset = PlaylistElementContents.Count - PlaylistElements.Count; if (Offset < 0) Offset = 0; Update(); for (int i = PlaylistElements.Count - 1; i >= 0; i--) { if (PlaylistElements[i].SelectSlide.Visible) { CurrentPlaylistElement = i; break; } } } break; case Keys.Left: _Interactions.HandleInput(KeyEvent); CurrentPlaylistElement = GetSelectedSelectionNr(); if (CurrentPlaylistElement != -1) { CPlaylists.Playlists[ActivePlaylistID].Songs[CurrentPlaylistElement + Offset].GameMode = PlaylistElementContents[CurrentPlaylistElement + Offset].Modes[PlaylistElements[CurrentPlaylistElement].SelectSlide.Selection]; UpdatePlaylist(); } break; case Keys.Right: _Interactions.HandleInput(KeyEvent); CurrentPlaylistElement = GetSelectedSelectionNr(); if (CurrentPlaylistElement != -1) { CPlaylists.Playlists[ActivePlaylistID].Songs[CurrentPlaylistElement + Offset].GameMode = PlaylistElementContents[CurrentPlaylistElement + Offset].Modes[PlaylistElements[CurrentPlaylistElement].SelectSlide.Selection]; UpdatePlaylist(); } break; } return true; } //default actions switch (KeyEvent.Key) { case Keys.Back: if (_Theme.ButtonPlaylistName.Selected) { _EditMode = EEditMode.PlaylistName; _Theme.ButtonPlaylistName.EditMode = true; } else ClosePlaylist(); break; case Keys.Enter: if (_Theme.ButtonPlaylistClose.Selected) { ClosePlaylist(); } else if (_Theme.ButtonPlaylistSing.Selected) { StartPlaylistSongs(); } else if (_Theme.ButtonPlaylistSave.Selected) { CPlaylists.SavePlaylist(ActivePlaylistID); } else if (_Theme.ButtonPlaylistDelete.Selected) { CPlaylists.DeletePlaylist(ActivePlaylistID); ClosePlaylist(); } else if (_Theme.ButtonPlaylistName.Selected) { if (_EditMode != EEditMode.PlaylistName) { _EditMode = EEditMode.PlaylistName; _Theme.ButtonPlaylistName.EditMode = true; } else { _EditMode = EEditMode.None; _Theme.ButtonPlaylistName.EditMode = false; } } break; } } } return true; }
public void drawEdit(int positionId, string prompt, string caption, int cursor_position, bool selected, EEditMode mode) { drawLink(positionId, prompt + caption, EAlignment.justify_left); if (selected) { switch (mode) { case EEditMode.alphanum_high: drawText(maxColumns - 3, 0, "ABC"); break; case EEditMode.alphanum_low: drawText(maxColumns - 3, 0, "abc"); break; case EEditMode.numeric: drawText(maxColumns - 3, 0, "123"); break; } } if (selected) { formSetCursor(prompt.Length + cursor_position, positionId); } }
public bool HandleMouse(MouseEvent MouseEvent) { _Interactions.HandleMouse(MouseEvent); if (CHelper.IsInBounds(CompleteRect, MouseEvent) && Visible) { //Scroll if (MouseEvent.Wheel > 0) { if (PlaylistElements.Count + Offset + MouseEvent.Wheel <= PlaylistElementContents.Count) { Offset += MouseEvent.Wheel; Update(); } return true; } else if (MouseEvent.Wheel < 0) { if (Offset + MouseEvent.Wheel >= 0) { Offset += MouseEvent.Wheel; Update(); } return true; } bool hover_set = false; for (int i = 0; i < PlaylistElements.Count; i++) { //Hover for playlist-element if (PlaylistElementContents.Count - 1 >= i && CHelper.IsInBounds(PlaylistElements[i].Background.Rect, MouseEvent)) { hover_set = true; CurrentPlaylistElement = i; _Interactions.SetInteractionToSelectSlide(PlaylistElements[CurrentPlaylistElement].SelectSlide); _Interactions.ProcessMouseMove(MouseEvent.X, MouseEvent.Y); } //Delete Entry with RB if (CHelper.IsInBounds(PlaylistElements[i].Background.Rect, MouseEvent) && MouseEvent.RB && PlaylistElements[i].Content != -1) { CPlaylists.Playlists[ActivePlaylistID].DeleteSong(PlaylistElements[i].Content); UpdatePlaylist(); return true; } } if (!hover_set) { CurrentPlaylistElement = -1; } switch (_EditMode) { //Normal mode case EEditMode.None: //LB actions if (MouseEvent.LB) { if (CurrentPlaylistElement != -1) { CPlaylists.Playlists[ActivePlaylistID].Songs[CurrentPlaylistElement + Offset].GameMode = PlaylistElementContents[CurrentPlaylistElement + Offset].Modes[PlaylistElements[CurrentPlaylistElement].SelectSlide.Selection]; UpdatePlaylist(); } if (_Theme.ButtonPlaylistClose.Selected) { ClosePlaylist(); return true; } else if (_Theme.ButtonPlaylistSing.Selected) { StartPlaylistSongs(); return true; } else if (_Theme.ButtonPlaylistSave.Selected) { CPlaylists.SavePlaylist(ActivePlaylistID); return true; } else if (_Theme.ButtonPlaylistDelete.Selected) { CPlaylists.DeletePlaylist(ActivePlaylistID); ClosePlaylist(); return true; } else if (_Theme.ButtonPlaylistName.Selected) { _EditMode = EEditMode.PlaylistName; _Theme.ButtonPlaylistName.EditMode = true; return true; } } //Change order with holding LB if (MouseEvent.LBH && CurrentPlaylistElement != -1 && PlaylistElementContents.Count > 0 && DragAndDropSongID == -1) { ChangeOrderSource = CurrentPlaylistElement + Offset; //Update of Drag/Drop-Texture if (ChangeOrderSource >= PlaylistElementContents.Count) return true; ChangeOrderElement = new PlaylistElement(PlaylistElements[CurrentPlaylistElement]); ChangeOrderElement.Background.Rect.Z = CSettings.zNear; ChangeOrderElement.Cover.Rect.Z = CSettings.zNear; ChangeOrderElement.SelectSlide.Rect.Z = CSettings.zNear; ChangeOrderElement.SelectSlide.RectArrowLeft.Z = CSettings.zNear; ChangeOrderElement.SelectSlide.RectArrowRight.Z = CSettings.zNear; ChangeOrderElement.Text1.Z = CSettings.zNear; ChangeOrderElement.Background.Texture = CTheme.GetSkinTexture(_Theme.TextureBackgroundName); ChangeOrderElement.Background.Color = BackgroundColor; OldMousePosX = MouseEvent.X; OldMousePosY = MouseEvent.Y; _EditMode = EEditMode.ChangeOrder; } if (!MouseEvent.LBH && DragAndDropSongID != -1) { EGameMode gm = EGameMode.TR_GAMEMODE_NORMAL; CSong song = CSongs.GetSong(DragAndDropSongID); if (song != null) { if (song.IsDuet) gm = EGameMode.TR_GAMEMODE_DUET; if (CurrentPlaylistElement != -1) { CPlaylists.Playlists[ActivePlaylistID].SongInsert(CurrentPlaylistElement + Offset, DragAndDropSongID, gm); UpdatePlaylist(); } else { if (MouseEvent.Y < PlaylistElements[0].Background.Rect.Y && Offset == 0) { CPlaylists.Playlists[ActivePlaylistID].SongInsert(0, DragAndDropSongID, gm); UpdatePlaylist(); } else { if (PlaylistElements.Count + Offset >= PlaylistElementContents.Count) { float min = 0f; for (int i = PlaylistElements.Count - 1; i >= 0; i--) { if (PlaylistElements[i].SelectSlide.Visible) { min = PlaylistElements[i].SelectSlide.Rect.Y + PlaylistElements[i].SelectSlide.Rect.H; break; } } if (MouseEvent.Y > min) { CPlaylists.Playlists[ActivePlaylistID].AddSong(DragAndDropSongID, gm); UpdatePlaylist(); ScrollToBottom(); } } } DragAndDropSongID = -1; UpdatePlaylist(); } } } break; case EEditMode.PlaylistName: _Interactions.SetInteractionToButton(_Theme.ButtonPlaylistName); CurrentPlaylistElement = -1; if (MouseEvent.LB) { if (_Theme.ButtonPlaylistName.Selected) { CPlaylists.Playlists[ActivePlaylistID].PlaylistName = _Theme.ButtonPlaylistName.Text.Text; CPlaylists.Playlists[ActivePlaylistID].SavePlaylist(); _EditMode = EEditMode.None; return true; } } else if (MouseEvent.RB) { if (_Theme.ButtonPlaylistName.Selected) { _Theme.ButtonPlaylistName.Text.Text = CPlaylists.Playlists[ActivePlaylistID].PlaylistName; _EditMode = EEditMode.None; _Theme.ButtonPlaylistName.EditMode = false; return true; } } break; case EEditMode.ChangeOrder: //Actions according to playlist-element //Update coords for Drag/Drop-Texture ChangeOrderElement.MouseMove(MouseEvent.X, MouseEvent.Y, OldMousePosX, OldMousePosY); OldMousePosX = MouseEvent.X; OldMousePosY = MouseEvent.Y; if (!MouseEvent.LBH) { if (CurrentPlaylistElement != -1 && CurrentPlaylistElement + Offset != ChangeOrderSource) { CPlaylists.Playlists[ActivePlaylistID].SongMove(ChangeOrderSource, CurrentPlaylistElement + Offset); UpdatePlaylist(); } else if (CurrentPlaylistElement == -1) { if (MouseEvent.Y < PlaylistElements[0].Background.Rect.Y && Offset == 0) { CPlaylists.Playlists[ActivePlaylistID].SongMove(ChangeOrderSource, 0); } else { if (PlaylistElements.Count + Offset >= PlaylistElementContents.Count) { float min = 0f; for (int i = PlaylistElements.Count - 1; i >= 0; i--) { if (PlaylistElements[i].SelectSlide.Visible) { min = PlaylistElements[i].SelectSlide.Rect.Y + PlaylistElements[i].SelectSlide.Rect.H; break; } } if (MouseEvent.Y > min) { CPlaylists.Playlists[ActivePlaylistID].SongMove(ChangeOrderSource, PlaylistElementContents.Count - 1); } } } UpdatePlaylist(); } _EditMode = EEditMode.None; } break; } } return false; }
public override bool HandleMouse(MouseEvent MouseEvent) { if (_EditMode == EEditMode.None) base.HandleMouse(MouseEvent); if (MouseEvent.LB && IsMouseOver(MouseEvent)) { if (Buttons[htButtons(ButtonExit)].Selected) { CGraphics.FadeTo(EScreens.ScreenMain); } else if (Buttons[htButtons(ButtonSave)].Selected) { SaveProfiles(); } else if (Buttons[htButtons(ButtonNew)].Selected) { NewProfile(); } else if (Buttons[htButtons(ButtonDelete)].Selected) { DeleteProfile(); } else if (Buttons[htButtons(ButtonPlayerName)].Selected) { if (CProfiles.NumProfiles > 0 && _EditMode != EEditMode.PlayerName) _EditMode = EEditMode.PlayerName; else _EditMode = EEditMode.None; } else if (SelectSlides[htSelectSlides(SelectSlideDifficulty)].Selected) { CProfiles.SetDifficulty(SelectSlides[htSelectSlides(SelectSlideProfiles)].Selection, (EGameDifficulty)SelectSlides[htSelectSlides(SelectSlideDifficulty)].Selection); } else if (SelectSlides[htSelectSlides(SelectSlideAvatars)].Selected) { CProfiles.SetAvatar(SelectSlides[htSelectSlides(SelectSlideProfiles)].Selection, SelectSlides[htSelectSlides(SelectSlideAvatars)].Selection); if (CWebcam.GetDevices().Length > 0 && _WebcamTexture.index > 0) OnDiscardSnapshot(); } else if (SelectSlides[htSelectSlides(SelectSlideGuestProfile)].Selected) { CProfiles.SetGuestProfile(SelectSlides[htSelectSlides(SelectSlideProfiles)].Selection, (EOffOn)SelectSlides[htSelectSlides(SelectSlideGuestProfile)].Selection); } else if (SelectSlides[htSelectSlides(SelectSlideActive)].Selected) { CProfiles.SetActive(SelectSlides[htSelectSlides(SelectSlideProfiles)].Selection, (EOffOn)SelectSlides[htSelectSlides(SelectSlideActive)].Selection); } else if (Buttons[htButtons(ButtonWebcam)].Selected && CWebcam.GetDevices().Length > 0) { OnWebcam(); } else if (Buttons[htButtons(ButtonSaveSnapshot)].Selected && CWebcam.GetDevices().Length > 0) { OnSaveSnapshot(); } else if (Buttons[htButtons(ButtonDiscardSnapshot)].Selected && CWebcam.GetDevices().Length > 0) { OnDiscardSnapshot(); } else if (Buttons[htButtons(ButtonTakeSnapshot)].Selected && CWebcam.GetDevices().Length > 0) { OnTakeSnapshot(); } } if (MouseEvent.RB) { CGraphics.FadeTo(EScreens.ScreenMain); } return true; }
//--------------------------------------------------------------------------- PUBLIC MEMBERS public void SetEditMode(EEditMode eEditMode) { // Sets the edit mode safely. (Needed if a hotspot is currently activated) if (_EditMode == eEditMode) return; if (_oHotSpotCurrent) { // Temporarily deactivate current hotspot... _oHotSpotCurrent.OnDeactivate(); _oHotSpotCurrent.OnHoverEnd(); } _EditMode = eEditMode; //... adopt the new mode... Debug.Log("Edit mode now set to '" + _EditMode.ToString() + "'"); if (_oHotSpotCurrent) { //... and re-activate hotspot with the new mode. This will re-initialize correctly for gizmo operation with the new mode _oHotSpotCurrent.OnHoverBegin(); _oHotSpotCurrent.OnActivate(true, false, false); } }
//public void OnPropSet_BtnUpdateBody(float nValueOld, float nValueNew) { //###BROKEN#11 // Debug.Log("CBody: Rebuilding body " + _oBodyBase._sBodyPrefix); // //Pose_Save("TEMP"); // Save the current pose to a temp file so we can restore body as it was right after rebuild // CGame.INSTANCE.CreateBody(_oBodyBase._nBodyID); // Will destroy 'this' and rebuild entire new tree of objects & meshes all the way from Blender // //Pose_Load("TEMP"); // Restore pose saved earlier // CGame.INSTANCE.Scene_Reload(); //###HACK? ###DESIGN: Reload whole scene to re-init position of newly created body //} //-------------------------------------------------------------------------- IHotspot interface public void OnHotspotChanged(CGizmo oGizmo, EEditMode eEditMode, EHotSpotOp eHotSpotOp) { }
public virtual void OnHotspotChanged(CGizmo oGizmo, EEditMode eEditMode, EHotSpotOp eHotSpotOp) { _oBody.SelectBody(); // Manipulating a body's hotspot automatically selects this body. switch (eEditMode) { case EEditMode.Move: Vector3 vecPosG = oGizmo.transform.position; //###NOTE: Upon hotspot movement we have to set not only our transform properties but CProp as well. Vector3 vecPosL; if (transform.name == "Base") // If the base actor is moving we set the global position otherwise we move the child actor relatve to the base actor ###IMPROVE: Test by type isntead of string! vecPosL = vecPosG; else vecPosL = transform.parent.worldToLocalMatrix.MultiplyPoint(vecPosG); // Convert the global hotspot position to be relative to the actor's parent (Usually 'Base' or 'Torso') _oObj.PropSet(EActorNode.PosX, vecPosL.x); //###NOTE: Setting EActorNode for all actors (all have same enum index for same pin properties) _oObj.PropSet(EActorNode.PosY, vecPosL.y); _oObj.PropSet(EActorNode.PosZ, vecPosL.z); transform.localPosition = vecPosL; break; case EEditMode.Rotate: Quaternion quatRotG = oGizmo.transform.rotation; //###DESIGN???: Problem with rotation? transform.rotation = quatRotG; //###WEAK!! ###OPT! Some work duplication with PropSet below setting our transform! Quaternion quatRotL = transform.localRotation; _oObj.PropSet(EActorNode.RotX, quatRotL.x); _oObj.PropSet(EActorNode.RotY, quatRotL.y); _oObj.PropSet(EActorNode.RotZ, quatRotL.z); _oObj.PropSet(EActorNode.RotW, quatRotL.w); break; } }