public static void DrawRectWithOutline(Rect rect, Color color, Color colorOutline) { if (Texture == null) { Texture = new Texture2D(1, 1); // Texture.SetPixel(0,0,colorOutline); Texture.SetPixel(0, 0, Color.green); Texture.Apply(); } Rect rLine = new Rect(rect.x, rect.y, rect.width, 2); AONGUI.DrawTexture(rLine, Texture); rLine.y = rect.y + rect.height - 1; AONGUI.DrawTexture(rLine, Texture); rLine = new Rect(rect.x, rect.y + 1, 2, rect.height - 2); AONGUI.DrawTexture(rLine, Texture); rLine.x = rect.x + rect.width - 1; AONGUI.DrawTexture(rLine, Texture); // Rect texCoord = new Rect( rect.x, rect.y, rect.width, rect.height ); // AONGUI.DrawTextureWithTexCoords(rect, Texture, texCoord); // rect.x += 1; // rect.y += 1; // rect.width -= 2; // rect.height -= 2; // Texture.SetPixel(0,0,color); // Texture.Apply(); // AONGUI.DrawTexture(rect, Texture); }
void OnGUITileSet() { if (m_startDragTileX != -1 && m_startDragTileY != -1) { Rect selRect = new Rect( ); selRect.width = (Mathf.Abs(m_dragTileX - m_startDragTileX) + 1) * m_camera2D.Zoom * m_autoTileMap.CellSize.x * AutoTileset.PixelToUnits; selRect.height = (Mathf.Abs(m_dragTileY - m_startDragTileY) + 1) * m_camera2D.Zoom * m_autoTileMap.CellSize.y * AutoTileset.PixelToUnits; float worldX = Mathf.Min(m_startDragTileX, m_dragTileX) * m_autoTileMap.CellSize.x; float worldY = -Mathf.Min(m_startDragTileY, m_dragTileY) * m_autoTileMap.CellSize.y; Vector3 vScreen = m_camera2D.Camera.WorldToScreenPoint(new Vector3(worldX, worldY) + m_autoTileMap.transform.position); //NOTE: vScreen will vibrate if the camera has KeepInsideMapBounds enabled and because of the zoom out, the camera area is bigger than camera limit bounds selRect.position = new Vector2(vScreen.x, vScreen.y); selRect.y = ScreenHeight() - selRect.y; UtilsGuiDrawing.DrawRectWithOutline(selRect, new Color(0f, 1f, 0f, 0.2f), new Color(0f, 1f, 0f, 1f)); // float yGui = m_rEditorRect.y + 32f; AONGUI.Label(new Rect(m_rEditorRect.x + 4f, yGui + 4f, m_rEditorRect.width - 8f, 32 - 8f), "Map: " + m_autoTileMap.MapIdxSelect); yGui += 16f; AONGUI.Label(new Rect(m_rEditorRect.x + 4f, yGui + 4f, m_rEditorRect.width - 8f, 32 - 8f), "x: " + m_startDragTileX); yGui += 16f; AONGUI.Label(new Rect(m_rEditorRect.x + 4f, yGui + 4f, m_rEditorRect.width - 8f, 32 - 8f), "y: " + m_startDragTileY); yGui += 32f; // AONGUI.Button(new Rect(m_rEditorRect.x, yGui, m_rEditorRect.width, 32), "Accept", () => { if (OnHadPickMap != null) { OnHadPickMap(this, m_startDragTileX, m_startDragTileY); } }); } }
protected override void OnGUIAON() { if (!m_isInitialized) { return; } // int tilesWidth = k_visualTileWidth * m_autoTileMap.Tileset.AutoTilesPerRow; // int tilesHeight = k_visualTileHeight * (256 / m_autoTileMap.Tileset.AutoTilesPerRow); // var m_rEditorRect = new Rect(0f, 0f, tilesWidth+2*fPad + fScrollBarWidth, ScreenHeight()); // var m_rMapViewRect = new Rect( m_rEditorRect.x + m_rEditorRect.width, 0f, ScreenWidth() - m_rEditorRect.width, ScreenHeight()); // float minimapRectW = Mathf.Min(m_rMapViewRect.width * 0.25f, m_autoTileMap.MinimapTexture.width); // fix to limit the size of minimap for big maps float fPad = 4f; float fScrollBarWidth = 16f; float tilesWidth = 32 * 8; float minimapRectW = tilesWidth + 2 * fPad + fScrollBarWidth; // float minimapRectW = ScreenWidth() * 0.2f; float minimapRectH = m_autoTileMap.MinimapTexture.height * minimapRectW / m_autoTileMap.MinimapTexture.width; float fOffset = 18f; var RectBox = new Rect(ScreenWidth() - minimapRectW, ScreenHeight() - minimapRectH, minimapRectW, minimapRectH); m_rMinimapRect = new Rect(RectBox.x + fOffset, RectBox.y + fOffset * 1.75f, RectBox.width - 2 * fOffset, RectBox.height - 2 * fOffset); float minimapScale = m_rMinimapRect.width / m_autoTileMap.MinimapTexture.width; //NOTE: the texture is drawn blurred in web player unless default quality is set to Fast in project settings // see here for solution http://forum.unity3d.com/threads/webplayer-gui-issue.100256/#post-868451 // UtilsGuiDrawing.DrawRectWithOutline( m_rMinimapRect, new Color(0, 0, 0, 0), Color.black ); AONGUI.Box(RectBox, "Mini Map (W,A,S,D to move)"); AONGUI.DrawTexture(m_rMinimapRect, m_autoTileMap.MinimapTexture); // Draw camera region on minimap Vector3 vCameraPos = m_autoTileMap.ViewCamera.ScreenPointToRay(new Vector3(-m_rMinimapRect.width, ScreenHeight() - 1)).origin; float camTileX = (vCameraPos.x / m_autoTileMap.CellSize.x); float camTileY = (-vCameraPos.y / m_autoTileMap.CellSize.y); Rect rMinimapCam = new Rect(camTileX, camTileY, minimapScale * ScreenWidth() / (m_camera2D.Zoom * m_autoTileMap.CellSize.x * AutoTileset.PixelToUnits), minimapScale * ScreenHeight() / (m_camera2D.Zoom * m_autoTileMap.CellSize.y * AutoTileset.PixelToUnits)); rMinimapCam.position *= minimapScale; rMinimapCam.position += m_rMinimapRect.position; //Clamp rMinimapCam if (rMinimapCam.xMin < m_rMinimapRect.x) { rMinimapCam.xMin = m_rMinimapRect.x; } if (rMinimapCam.xMax > m_rMinimapRect.xMax) { rMinimapCam.xMax = m_rMinimapRect.xMax; } if (rMinimapCam.yMin < m_rMinimapRect.y) { rMinimapCam.yMin = m_rMinimapRect.y; } if (rMinimapCam.yMax > m_rMinimapRect.yMax) { rMinimapCam.yMax = m_rMinimapRect.yMax; } UtilsGuiDrawing.DrawRectWithOutline(rMinimapCam, new Color(0, 0, 0, 0), Color.white); }
public static void OnGuiDebug(Flags flags, Rect rect, float limitHeight) { if (flags == null) { AONGUI.Label(new Rect(rect.x, rect.y + DefineAON.GUI_Y_Label, 150, DefineAON.GUI_Height_Label), "Empty"); return; } var keys = flags.Keys; // float w = 200; float contentHeight = 24f * (keys.Count) + 8; if (contentHeight < limitHeight) { limitHeight = contentHeight; if (limitHeight < 100) { limitHeight = 100; } } // Rect rect = new Rect( 8, Screen.height - limitHeight - 8, w, limitHeight); // GUI.Box( rect, "" ); // GUI.DrawTexture( rect, GUI.skin.box.normal.background, ScaleMode.StretchToFill); bool hasScroll = contentHeight > limitHeight; rect.width = rect.width - 16f; if (hasScroll) { Rect view = new Rect(rect.x, rect.y, rect.width + 16f, rect.height); Rect listRect = new Rect(rect.x, rect.y, rect.width, contentHeight); AONGUI.BeginScrollView(view, m_scrollPos, listRect, false, false, (Vector2 v) => { m_scrollPos = v; }); // GUI.Box(listRect, ""); } float yGui = rect.y + 4; foreach (string key in keys) { AONGUI.Label(new Rect(rect.x, yGui, rect.width - 8, 24f), string.Format("{0} : {1}", key, flags[key])); yGui += 24f; } if (hasScroll) { AONGUI.EndScrollView(); } }
private bool OnGUIMenuLeft(TilesetAON tilesetAON, ref float yGui, Rect rect) { // Flag // yGui += 16; int current = (int)mMenuLeft; float h = StrMenuLeft.Length * 32; AONGUI.SelectionGrid(new Rect(rect.x, yGui, rect.width, h), current, StrMenuLeft, 1, tilesetAON.ListStyleGrid, (int next) => { mMenuLeft = (EMenuLeft)next; }); yGui += h; return(false); }
public static void KeyValueOnGUI(Flags flagsYaml, string key, ref float yGui, Rect rect, bool lockKey, List <string> resetList, int index) { int value = flagsYaml.ContainsKey(key) ? flagsYaml[key] : 0; float _w2 = 50; float _w3 = 60; float _wReset = resetList == null ? 0 : 100; float _w = (rect.width - _w2 - _w3 - _wReset - 8) / 2; float xGui = rect.x + 4; AONGUI.Label(new Rect(xGui, yGui + 32 - heighTextField, _w, heighTextField), key); xGui += _w; AONGUI.Label(new Rect(xGui + _w2 / 2, yGui, _w2, 32), "="); xGui += _w2; AONGUI.TextField(new Rect(xGui, yGui + 32 - heighTextField, _w, heighTextField), value.ToString(), 25, (string text) => { flagsYaml[key] = UtilsAON.StrToIntDef(text); }); xGui += _w; if (lockKey == false) { AONGUI.Button(new Rect(xGui, yGui + 32 - heighTextField, _w3, heighTextField), "Remove", () => { flagsYaml.Remove(key); //Check clear cache comboBoxFlags if (_instance != null && _instance.flagsCurrent == flagsYaml) { _instance.ResetCombobox(); } }); } xGui += _w3; if (resetList != null) { if (index == 0) { AONGUI.Label(new Rect(xGui + _wReset - 120, yGui - 18 + DefineAON.GUI_Y_Label, 120, DefineAON.GUI_Height_Label), "Reset when interact"); } bool isReset = resetList.IndexOf(key) >= 0; string v = " Reset"; AONGUI.Toggle(new Rect(xGui + _wReset - 60, yGui + 8 + DefineAON.GUI_Y_Label, 60, DefineAON.GUI_Height_Label), isReset, v, (bool resetNext) => { if (resetNext) { resetList.Add(key); } else { resetList.Remove(key); } }); } // xGui += _wReset; yGui += 32f; }
public void OnGUI(SerializablePackages packages, SerializablePropertys propertys, List <FlagAction> listFlagAction, TilesetAON tilesetAON, Rect rect) { float height_top = 68; AONGUI.Box(new Rect(rect.x, rect.y, rect.width, height_top), "", tilesetAON.ListStyleBlack2); if (OnTopMenu(packages, tilesetAON, new Rect(rect.x, rect.y, rect.width, rect.height))) { return; } if (OnGuiBot(packages, propertys, listFlagAction, tilesetAON, new Rect(rect.x, height_top, rect.width, rect.height))) { return; } }
public void OnGUI() { // int w = Screen.width, h = Screen.height; style.alignment = TextAnchor.UpperLeft; style.fontSize = 14; style.normal.textColor = new Color(0.0f, 0.0f, 0.5f, 1.0f); // string text = string.Format("{0:0.0} ms ({1:0.} fps)", msec, fps); string text = string.Format("{0:0.} fps", fps); Rect rect = new Rect(4, 0, Screen.width, 25); AONGUI.Label(rect, text, style); // GUI.Label(rect, text, style); }
public void OnGUITip() { if (mTip != null && mTip != "") { float w = 400; float widthContent = w - 16; var listStyleLabel = AONGUI.skin.label; GUIContent g = new GUIContent(mTip); float h_title = listStyleLabel.CalcHeight(g, widthContent) + 8 + 8; float h = h_title + 16; Rect rect = new Rect((Screen.width - w) / 2, Screen.height - 24f - h, w, h); AONGUI.Box(rect, ""); AONGUI.Label(new Rect(rect.x + 8, rect.y + 8, widthContent, h_title), g); } }
protected override void OnGUIAON() { if (!m_isInitialized) { return; } float fPad = 4f; float fScrollBarWidth = 16f; int tilesWidth = k_visualTileWidth * TilesetAON.AutoTilesPerRow; float w = tilesWidth + 2 * fPad + fScrollBarWidth; m_rEditorRect = new Rect(Screen.width - w, 0f, w, ScreenHeight() - w); AONGUI.Box(m_rEditorRect, "Pick position"); OnGUITileSet(); }
private bool OnTopMenu(SerializablePropertys data, TilesetAON tilesetAON, Rect rect) { float widthLeft = 200; //menu float yGui = rect.y; AONGUI.Label(new Rect(rect.x + 4, yGui + DefineAON.GUI_Y_Label, widthLeft, DefineAON.GUI_Height_Label), "Property edit :"); yGui += 32f; float xGui = rect.x + 4; AONGUI.Label(new Rect(xGui, yGui + DefineAON.GUI_Y_Label, 90, DefineAON.GUI_Height_Label), "Slug property"); xGui += 94; AONGUI.TextField(new Rect(xGui, yGui + DefineAON.GUI_Y_TextField, 200, DefineAON.GUI_Height_TextField), slugNameAdd, (string text) => { slugNameAdd = text; }); xGui += 204; if (slugNameAdd.Length == 0) { // GUI.Label(new Rect( rect.x, yGui + DefineAON.GUI_Y_Label, 200, DefineAON.GUI_Height_Label ), "Input slug property"); } else { bool isUnique = true; var keys = data.AllKey; for (int i = 0; i < keys.Count; i++) { if (keys[i] == slugNameAdd) { isUnique = false; break; } } if (isUnique) { AONGUI.Button(new Rect(xGui, yGui + DefineAON.GUI_Y_Button, 80, DefineAON.GUI_Height_Button), "Add (Enter)", KeyCode.Return, () => { data.Add(slugNameAdd); slugNameAdd = ""; }); } else { AONGUI.Label(new Rect(xGui, yGui + DefineAON.GUI_Y_Label, widthLeft, DefineAON.GUI_Height_Label), "Slug should be unique"); } } return(false); }
public bool WarpOnGUI(Warps warp, Rect rect, AutoTileMap autoTileMap, TilesetAON tilesetAON) { bool hasUpdateUI = false; float left = 80f; // Input Name float yGui = rect.y + 8f; AONGUI.Label(new Rect(rect.x, yGui, rect.width, 32f), string.Format("Edit Warp {0}", warp.NameWarps)); yGui += 32; AONGUI.Label(new Rect(rect.x, yGui, left, 32), "Name: "); AONGUI.TextField(new Rect(rect.x + left, yGui + 32 - heighTextField, rect.width - left, heighTextField), warp.NameWarps, 25, (string text) => { warp.NameWarps = text; }); yGui += 32; // Pick Map AONGUI.Label(new Rect(rect.x, yGui, left, 32), "Map: "); var ComboBoxMap = ComboBoxHelper.Instance.MapList(autoTileMap); ComboBoxMap.SelectedItemIndex = warp.map; ComboBoxMap.Rect.x = rect.x + left; ComboBoxMap.Rect.y = yGui; ComboBoxMap.Rect.width = rect.width - left; ComboBoxMap.Rect.height = 32f; ComboBoxMap.Show(rect.height - yGui - 32, (int selectedMap) => { warp.map = selectedMap; }); yGui += 32f; if (ComboBoxMap.IsDropDownListVisible) { return(hasUpdateUI); } if (warp.map != -1) { AONGUI.Label(new Rect(rect.x + 4f, yGui + 4f, rect.width - 8f, 32 - 8f), "x: " + warp.x); yGui += 16f; AONGUI.Label(new Rect(rect.x + 4f, yGui + 4f, rect.width - 8f, 32 - 8f), "y: " + warp.y); yGui += 32f; AONGUI.Button(new Rect(rect.x, yGui, rect.width, 32), "Select position on map...", () => { tilesetAON.PickPosOnMap(warp.map, warp.x, warp.y, (PickMapAON p, int _x, int _y) => { warp.x = _x; warp.y = _y; }); }); } return(hasUpdateUI); }
public void OnGUI(SerializablePropertys data, List <FlagAction> listFlagAction, TilesetAON tilesetAON, Rect rect) { float height_top = 68; AONGUI.Box(new Rect(rect.x, rect.y, rect.width, height_top), "", tilesetAON.ListStyleBlack2); AONGUI.Button(new Rect(rect.x + rect.width - 170, rect.y + DefineAON.GUI_Y_Button, 160, DefineAON.GUI_Height_Button), "Import full from Resource", () => { _importAllFromResource(data); }); if (OnTopMenu(data, tilesetAON, new Rect(rect.x, rect.y, rect.width, rect.height))) { return; } if (OnGuiBot(data, listFlagAction, tilesetAON, new Rect(rect.x, height_top, rect.width, rect.height))) { return; } }
private void OnGuiShowHighlight(int idxChoise, Rect r, GUIContent g_c, ScriptGui.MsgboxChoise choise) { ScriptGui.MsgboxChoise.ETypeHighlight type = (ScriptGui.MsgboxChoise.ETypeHighlight)choise.TypeHighlight; bool isPick = idxChoise == mNextIdxChoiseInHighlight; bool isRight = type == ScriptGui.MsgboxChoise.ETypeHighlight.Full_Green; if (isPick) { if (isRight) { AONGUI.Label(r, g_c, GUISkinIngame.customStyles[3]); AONGUI.DrawTexture(new Rect(r.x + r.width - 32, r.y + r.height - 32, 32, 32), GUISkinIngame.customStyles[3].hover.background); } else { if (type == ScriptGui.MsgboxChoise.ETypeHighlight.Words_Red && !string.IsNullOrEmpty(choise.ContentHighlight)) { var style = GUISkinIngame.customStyles[0]; var red = GUISkinIngame.customStyles[2]; var b = choise.Value.IndexOf(choise.ContentHighlight); if (b >= 0) { // var s1 = choise.Value.Substring(0, b); // var c1 = new GUIContent(s1); var p_sup = style.GetCursorPixelPosition(r, g_c, b); var s_sup = style.CalcSize(new GUIContent(choise.ContentHighlight)); AONGUI.Label(new Rect(p_sup.x - 5, p_sup.y - 2, s_sup.x, s_sup.y), "", red); // GUI.Label(r, g_c, style); } } AONGUI.Label(r, g_c, GUISkinIngame.customStyles[4]); AONGUI.DrawTexture(new Rect(r.x + r.width - 32, r.y + r.height - 32, 32, 32), GUISkinIngame.customStyles[4].hover.background); } } else { if (isRight) { AONGUI.Label(r, g_c, GUISkinIngame.customStyles[1]); } else { AONGUI.Label(r, g_c, GUISkinIngame.customStyles[5]); } } }
public bool HouseOnGUIWithNPC(House house, House.NpcInHouse npc, Rect rect, AutoTileMap autoTileMap, TilesetAON tilesetAON, ref float yGui) { { float left = 80f; AONGUI.Label(new Rect(rect.x, yGui, left, 28), "Npc ref:"); var comboBox = ComboBoxHelper.Instance.NPCList(autoTileMap.MapSelect); comboBox.SelectedItemIndex = npc.IdxNPC; comboBox.Rect.x = rect.x + left; comboBox.Rect.y = yGui; comboBox.Rect.width = rect.width - left; comboBox.Rect.height = 32f; if (comboBox.IsDropDownListVisible) { AONGUI.Button(new Rect(rect.x + left, rect.y + rect.height - 64, rect.width - left, 28), "Add NPC", () => { npc.IdxNPC = autoTileMap.MapSelect.CreateNewNPC(); }); return(true); } comboBox.Show(rect.height - yGui - 64, (int selectedNpc) => { npc.IdxNPC = selectedNpc; }); yGui += 32f; if (comboBox.IsDropDownListVisible) { return(true); } } if (npc.IdxNPC >= 0 && npc.IdxNPC < autoTileMap.MapSelect.NPCData.Count) { AONGUI.Button(new Rect(rect.x + rect.width - 100, yGui, 100, 28), "Edit NPC", () => { tilesetAON.TriggerShowMoreInfo = autoTileMap.MapSelect.NPCData[npc.IdxNPC]; }); } yGui += 32f; AONGUI.Button(new Rect(rect.x, yGui, rect.width, 28), "Setup pos and face NPC", () => { tilesetAON.PickPosOnInterior(house.IdxInterior, npc.NPC_OffsetOut, npc.NPC_CamOut, (TilesetAON t, Vector3 p, Vector3 cam) => { npc.NPC_OffsetOut = p; npc.NPC_CamOut = cam; }); }); yGui += 32f; return(false); }
private void OnGuiGeneral(TilesetAON tilesetAON, AutoTileMap autoTileMap, Rect rect) { float yBeginGui = rect.y + 4f; AONGUI.Label(new Rect(rect.x + 10f, yBeginGui, 200, DefineAON.GUI_Height_Label), "Map " + autoTileMap.MapIdxSelect); // yBeginGui += 32; AONGUI.Button(new Rect(rect.x + rect.width - 220, yBeginGui, 200, DefineAON.GUI_Height_Label), "Reset map", () => { tilesetAON._isShowDialogClearMap = true; }); yBeginGui += 32; AONGUI.Label(new Rect(rect.x + 10f, yBeginGui, rect.width - 8f, DefineAON.GUI_Height_Label), string.Format("Start at: ({0}, {1})", autoTileMap.MapSelect.StartX, autoTileMap.MapSelect.StartY)); yBeginGui += 32; AONGUI.Button(new Rect(rect.x + 10f, yBeginGui, 200, DefineAON.GUI_Height_Button), "Pick start position", () => { tilesetAON.PickPosOnMap(autoTileMap.MapIdxSelect, autoTileMap.MapSelect.StartX, autoTileMap.MapSelect.StartY, (PickMapAON p, int _x, int _y) => { autoTileMap.MapSelect.StartX = _x; autoTileMap.MapSelect.StartY = _y; }); }); }
public bool HouseOnGUI(House house, Rect rect, AutoTileMap autoTileMap, TilesetAON tilesetAON) { bool hasUpdateUI = false; float left = 80f; // Input Name float yGui = rect.y + 8f; float heighTextField = 20f; AONGUI.Label(new Rect(rect.x, yGui, rect.width, 32f), string.Format("Edit House {0}", house.NameHouse)); yGui += 32; AONGUI.Label(new Rect(rect.x, yGui, left, 32), "Name: "); AONGUI.TextField(new Rect(rect.x + left, yGui + 32 - heighTextField, rect.width - left, heighTextField), house.NameHouse, 25, (string text) => { house.NameHouse = text; }); yGui += 32; #region Art { AONGUI.Label(new Rect(rect.x, yGui, left, 32), "House: "); var comboBoxHouseList = ComboBoxHelper.Instance.HouseListModel(autoTileMap); comboBoxHouseList.SelectedItemIndex = house.IdxArt; comboBoxHouseList.Rect.x = rect.x + left; comboBoxHouseList.Rect.y = yGui; comboBoxHouseList.Rect.width = rect.width - left; comboBoxHouseList.Rect.height = 32f; comboBoxHouseList.Show(rect.height - yGui - 32, (int selectedArt) => { house.IdxArt = selectedArt; // int tx = tilesetAON.TileShowMoreInfo.TileX; int ty = tilesetAON.TileShowMoreInfo.TileY; // var slot = autoTileMap.Tileset.GetSlot(tilesetAON.TileShowMoreInfo.Id); autoTileMap.TileChunkPoolNode.GetTileChunk(tx, ty, (int)tilesetAON.TileShowMoreInfo.Layer).RefreshTileOverlay(tx, ty, true); }); yGui += 32f; if (comboBoxHouseList.IsDropDownListVisible) { return(hasUpdateUI); } } #endregion if (house.IdxArt == -1) { return(hasUpdateUI); } #region Go In if (tilesetAON.TileShowMoreInfo != null) { int xOffsetIn = 0, yOffsetIn = 0; int tx = tilesetAON.TileShowMoreInfo.TileX; int ty = tilesetAON.TileShowMoreInfo.TileY; var rotateRef = autoTileMap.MapSelect.GetRotateRef(tx, ty) % 360; house.GetOffsetFromRotate(ref xOffsetIn, ref yOffsetIn, rotateRef); AONGUI.Label(new Rect(rect.x + 4f, yGui + 4f, rect.width - 8f, 32 - 8f), string.Format("Go in at: ({0} ,{1})", xOffsetIn, yOffsetIn)); yGui += 32f; AONGUI.Button(new Rect(rect.x, yGui, rect.width, 32), "Pick go in", () => { tilesetAON.PickPosOnMap(autoTileMap.MapIdxSelect, tilesetAON.TileShowMoreInfo.TileX + xOffsetIn, tilesetAON.TileShowMoreInfo.TileY + yOffsetIn, (PickMapAON p, int _x, int _y) => { // house.XOffsetIn = _x - tilesetAON.TileShowMoreInfo.TileX; // house.YOffsetIn = _y - tilesetAON.TileShowMoreInfo.TileY; house.SetOffsetFromRotate(_x - tilesetAON.TileShowMoreInfo.TileX, _y - tilesetAON.TileShowMoreInfo.TileY, rotateRef); }); }); yGui += 32f; } #endregion //Door #region Interior { AONGUI.Label(new Rect(rect.x, yGui, left, 32), "Interior: "); var comboBoxInteriorList = ComboBoxHelper.Instance.InteriorList(autoTileMap); comboBoxInteriorList.SelectedItemIndex = house.IdxInterior; comboBoxInteriorList.Rect.x = rect.x + left; comboBoxInteriorList.Rect.y = yGui; comboBoxInteriorList.Rect.width = rect.width - left; comboBoxInteriorList.Rect.height = 32f; comboBoxInteriorList.Show(rect.height - yGui - 32, (int selectedInterior) => { house.IdxInterior = selectedInterior; }); yGui += 32f; if (comboBoxInteriorList.IsDropDownListVisible) { return(hasUpdateUI); } } #endregion if (house.IdxInterior == -1) { return(hasUpdateUI); } #region Go Out // GUI.Label(new Rect(rect.x+ 4f, yGui + 4f, rect.width - 8f, 32 - 8f), string.Format("Go out at: {0}", house.OffsetOut.ToString())); // yGui += 32f; // GUI.Label(new Rect(rect.x+ 4f, yGui + 4f, rect.width - 8f, 32 - 8f), string.Format("Cam: {0}", house.CamOut.ToString())); // yGui += 32f; AONGUI.Button(new Rect(rect.x, yGui, rect.width, 32), "Pick go out and camera", () => { tilesetAON.PickPosOnInterior(house.IdxInterior, house.OffsetOut, house.CamOut, (TilesetAON t, Vector3 p, Vector3 cam) => { house.OffsetOut = p; house.CamOut = cam; }); }); yGui += 32f; #endregion //Door // yGui += 16f; if (house.NpcInHouses.Count == 0) { AONGUI.Button(new Rect(rect.x, yGui, rect.width, 32), "Add NPC Inhouse", () => { house.NpcInHouses.Add(new House.NpcInHouse()); currentIdNpcTager = 0; }); return(false); } AONGUI.Label(new Rect(rect.x, yGui, left, 28), "Slot NPC: "); var comboBoxCount = ComboBoxHelper.Instance.Number(house.NpcInHouses.Count); comboBoxCount.SelectedItemIndex = currentIdNpcTager; comboBoxCount.Rect.x = rect.x + left; comboBoxCount.Rect.y = yGui; comboBoxCount.Rect.width = rect.width - left; comboBoxCount.Rect.height = 32f; if (comboBoxCount.IsDropDownListVisible) { AONGUI.Button(new Rect(rect.x + left, rect.y + rect.height - 64, rect.width - left, 28), "Add Slot", () => { house.NpcInHouses.Add(new House.NpcInHouse()); currentIdNpcTager = house.NpcInHouses.Count - 1; }); } comboBoxCount.Show(rect.height - yGui - 64, (int next) => { currentIdNpcTager = next; }); if (comboBoxCount.IsDropDownListVisible) { return(hasUpdateUI); } yGui += 32f; if (currentIdNpcTager >= 0 && currentIdNpcTager < house.NpcInHouses.Count) { if (HouseOnGUIWithNPC(house, house.NpcInHouses[currentIdNpcTager], rect, autoTileMap, tilesetAON, ref yGui)) { return(hasUpdateUI); } } return(hasUpdateUI); }
public bool NPCOnGUI(NPC npc, Rect rect, AutoTileMap autoTileMap, TilesetAON tilesetAON) { bool hasUpdateUI = false; float left = 80f; // Input Name float yGui = rect.y + 8f; AONGUI.Label(new Rect(rect.x, yGui, rect.width, 32f), string.Format("Edit NPC {0}", npc.NameNPC)); yGui += 32; AONGUI.Label(new Rect(rect.x, yGui, left, 32), "Name: "); AONGUI.TextField(new Rect(rect.x + left, yGui + 32 - heighTextField, rect.width - left, heighTextField), npc.NameNPC, 25, (string text) => { npc.NameNPC = text; }); yGui += 32; #region Art { AONGUI.Label(new Rect(rect.x, yGui, left, 32), "Model: "); var comboBoxNPCModel = ComboBoxHelper.Instance.NPCModel(autoTileMap); comboBoxNPCModel.SelectedItemIndex = npc.IdxArt; comboBoxNPCModel.Rect.x = rect.x + left; comboBoxNPCModel.Rect.y = yGui; comboBoxNPCModel.Rect.width = rect.width - left; comboBoxNPCModel.Rect.height = 32f; comboBoxNPCModel.Show(rect.height - yGui - 32, (int selectedArt) => { npc.IdxArt = selectedArt; }); if (comboBoxNPCModel.IsDropDownListVisible) { return(hasUpdateUI); } } yGui += 32f; #endregion yGui += 16f; #region Script AONGUI.Toggle(new Rect(rect.x, yGui, rect.width, 32), npc.StartScript, "Run Script when Start map", (bool b) => { npc.StartScript = b; }); yGui += 32f; if (npc.StartScript) { if (autoTileMap.MapSelect.ScriptData.Count == 0) { AONGUI.Label(new Rect(rect.x, yGui, left, 32), "Script: NULL"); yGui += 32f; AONGUI.Button(new Rect(rect.x, yGui, rect.width, 32), "Create new script", () => { npc.IdxStartScript = autoTileMap.MapSelect.CreateNewScript(); }); } else { AONGUI.Label(new Rect(rect.x, yGui, left, 32), "Script: "); var comboBox = ComboBoxHelper.Instance.Scripts(autoTileMap.MapSelect); comboBox.SelectedItemIndex = npc.IdxStartScript; comboBox.Rect.x = rect.x + left; comboBox.Rect.y = yGui; comboBox.Rect.width = rect.width - left; comboBox.Rect.height = 32f; string hash = "Start"; if (comboBox.IsDropDownWithHash(hash)) { AONGUI.Button(new Rect(rect.x, rect.y + rect.height - 64, rect.width, 32), "Create new script", () => { npc.IdxStartScript = autoTileMap.MapSelect.CreateNewScript(); }); } comboBox.Show(rect.height - yGui - 64, hash, (int selectedScript) => { npc.IdxStartScript = selectedScript; }); if (comboBox.IsDropDownWithHash(hash)) { return(hasUpdateUI); } } yGui += 32f; if (npc.IdxStartScript >= 0 && npc.IdxStartScript < autoTileMap.MapSelect.ScriptData.Count) { var w = (rect.width - left) / 2; AONGUI.Button(new Rect(rect.x + rect.width - w, yGui, w, 28), "Edit Script", () => { tilesetAON.TriggerShowMoreInfo = autoTileMap.MapSelect.ScriptData[npc.IdxStartScript]; }); } } yGui += 32f; yGui += 16f; AONGUI.Toggle(new Rect(rect.x, yGui, rect.width, 32), npc.RunScript, "Run Script when Talking", ( bool b) => { npc.RunScript = b; }); yGui += 32f; if (npc.RunScript) { if (autoTileMap.MapSelect.ScriptData.Count == 0) { AONGUI.Label(new Rect(rect.x, yGui, left, 32), "Script: NULL"); yGui += 32f; AONGUI.Button(new Rect(rect.x, yGui, rect.width, 32), "Create new script", () => { npc.IdxScript = autoTileMap.MapSelect.CreateNewScript(); }); } else { AONGUI.Label(new Rect(rect.x, yGui, left, 32), "Script: "); var comboBox = ComboBoxHelper.Instance.Scripts(autoTileMap.MapSelect); comboBox.SelectedItemIndex = npc.IdxScript; comboBox.Rect.x = rect.x + left; comboBox.Rect.y = yGui; comboBox.Rect.width = rect.width - left; comboBox.Rect.height = 32f; string hash = "Talk"; if (comboBox.IsDropDownWithHash(hash)) { AONGUI.Button(new Rect(rect.x, rect.y + rect.height - 64, rect.width, 32), "Create new script", () => { npc.IdxScript = autoTileMap.MapSelect.CreateNewScript(); }); } comboBox.Show(rect.height - yGui - 64, hash, (int selectedScript) => { npc.IdxScript = selectedScript; }); if (comboBox.IsDropDownWithHash(hash)) { return(hasUpdateUI); } } yGui += 32f; if (npc.IdxScript >= 0 && npc.IdxScript < autoTileMap.MapSelect.ScriptData.Count) { var w = (rect.width - left) / 2; AONGUI.Button(new Rect(rect.x + rect.width - w, yGui, w, 28), "Edit Script", () => { tilesetAON.TriggerShowMoreInfo = autoTileMap.MapSelect.ScriptData[npc.IdxScript]; }); } yGui += 32f; } #endregion return(hasUpdateUI); }
public void OnGUIChat() { if (mMsgboxChat != null) { if (mIndextChat < 0 || mIndextChat >= mMsgboxChat.MsgboxChat.Count) { EndMsg(); return; } float w = 400; var listStyleLabel = AONGUI.skin.label; var listStyleButton = AONGUI.skin.button; float calcHeight = 0; float widthContent = w - 16; List <float> h_Titles = new List <float>(); List <GUIContent> contentChoises = new List <GUIContent>(); List <float> h_Choises = new List <float>(); // calcHeight calcHeight += 8; for (int i = 0; i < mMsgLog.Count; i++) { MLog g = mMsgLog[i]; float h_title = listStyleLabel.CalcHeight(new GUIContent(g.text), widthContent) + 8; calcHeight += h_title; h_Titles.Add(h_title); calcHeight += 4; } if (mMsgChat.Count > 0) { foreach (MLog g in mMsgChat) { float h_title = listStyleLabel.CalcHeight(new GUIContent(g.text), widthContent) + 8; calcHeight += h_title; h_Titles.Add(h_title); calcHeight += 4; } } bool isHaveButonNext = false; float h_next = 0; GUIContent g_next = null; if (mMsgChoise != null && mMsgChoise.Count > 0) { foreach (var c in mMsgChoise) { // GUIContent g_c = new GUIContent(c.Value != "" ? c.Value : ( c.Next != null ? "Next" : "Close")); GUIContent g_c = new GUIContent(c.choise.Value != "" ? c.choise.Value : (c.choise.Next != null ? "Next" : "")); float h_c = 0; int to_scope = (c.choise.Next == null ? -1: mScriptGameMSG.Script.ListActions().IndexOf(c.choise.Next)); if (to_scope == -1) { h_c = listStyleLabel.CalcHeight(g_c, widthContent); } else { h_c = listStyleButton.CalcHeight(g_c, widthContent); isHaveButonNext = true; } contentChoises.Add(g_c); h_Choises.Add(h_c); calcHeight += 8; calcHeight += h_c; calcHeight += 8; } } if (isHaveButonNext == false) { g_next = new GUIContent((mIndextChat >= mMsgboxChat.MsgboxChat.Count - 1) ? "Close" : "Next"); h_next = listStyleButton.CalcHeight(g_next, widthContent); calcHeight += 8; calcHeight += h_next; calcHeight += 8; } // Render // Rect rect = new Rect((Screen.width - w) / 2, Screen.height - 24f - calcHeight, w, calcHeight); Rect rect = new Rect((Screen.width - w) / 2, 24f, w, calcHeight); bool touchOnDialog = false; if (mNextIdxChoiseInHighlight == -1) { AONGUI.Box(rect, ""); } else { AONGUI.Button(rect, "", GUISkinIngame.box, () => { touchOnDialog = true; }); } float yGui = rect.y; yGui += 8; int count_title = 0; for (int i = 0; i < mMsgLog.Count; i++) { MLog g = mMsgLog[i]; float h_title = h_Titles[count_title]; count_title++; AONGUI.Label(new Rect(rect.x + 8, yGui, widthContent, h_title), new GUIContent(g.text)); yGui += h_title; yGui += 4; } if (mMsgChat.Count > 0) { for (int j = 0; j < mMsgChat.Count; j++) { float h_title = h_Titles[count_title]; count_title++; AONGUI.Label(new Rect(rect.x + 8, yGui, widthContent, h_title), mMsgChat[j].text); yGui += h_title; yGui += 4; } } if (mMsgChoise != null && mMsgChoise.Count > 0) { var dataCheck = mMsgboxChat.MsgboxChat[mIndextChat]; bool isCheckHighlight = mMsgChoise.Count > 0 && dataCheck.Highlight; for (int idxChoise = 0; idxChoise < mMsgChoise.Count; idxChoise++) { var c = mMsgChoise[idxChoise]; int to_scope = (c.choise.Next == null ? -1: mScriptGameMSG.Script.ListActions().IndexOf(c.choise.Next)); GUIContent g_c = contentChoises[idxChoise]; float h_c = h_Choises[idxChoise]; if (to_scope == -1) { AONGUI.Label(new Rect(rect.x + 8, yGui, widthContent, h_c + 8), g_c); } else { var r = new Rect(rect.x + 8, yGui, widthContent, h_c + 8); if (c.choise.Value == "") { r = new Rect(rect.x + rect.width - 58, yGui, 50, h_c + 8); } if (isCheckHighlight && mNextIdxChoiseInHighlight != -1) { if (!touchOnDialog) { OnGuiShowHighlight(idxChoise, r, g_c, c.choise); } else { if (idxChoise == mNextIdxChoiseInHighlight) { //Save Log with Right value ScriptGui.MsgboxChoise choiseRight = null; for (int idxR = 0; idxR < mMsgChoise.Count; idxR++) { var cCheck = mMsgChoise[idxR]; if ((ScriptGui.MsgboxChoise.ETypeHighlight)cCheck.choise.TypeHighlight == ScriptGui.MsgboxChoise.ETypeHighlight.Full_Green) { choiseRight = cCheck.choise; break; } } if (choiseRight != null && !string.IsNullOrEmpty(choiseRight.Value)) { mMsgLog.Add(new MLog() { text = choiseRight.Value }); } else if (!string.IsNullOrEmpty(c.choise.Value)) { mMsgLog.Add(new MLog() { text = c.choise.Value }); } RefreshLog(); //End Save Log mNextIdxChoiseInHighlight = -1; GoNextChoise(c.choise); return; } } } else { AONGUI.Button(r, g_c, () => { // Not show Highlight if (isCheckHighlight) { // Set show Highlight mNextIdxChoiseInHighlight = idxChoise; } else { if (g_c.text != null && g_c.text != "" && g_c.text != "Close" && g_c.text != "Next") { mMsgLog.Add(new MLog() { text = g_c.text }); RefreshLog(); } GoNextChoise(c.choise); } }); } } // if(choise.Next != null && scriptTarget.Main.IndexOf(choise.Next))) yGui += 8; yGui += h_c; yGui += 8; } } if (isHaveButonNext == false) { AONGUI.Button(new Rect(rect.x + rect.width - 68, yGui, 60, h_next + 8), g_next, () => { mIndextChat++; if (mIndextChat >= mMsgboxChat.MsgboxChat.Count) { EndMsg(); } else { SetupChoise(0); } }); } return; } }
public static void DisOnGUI(Flags flagsYaml, ref float yGui, Rect rect, string[] lockKey = null, GUIStyle backgroundTop = null, string title = "Flag edit :", List <string> resetList = null) { if (backgroundTop != null) { float height_top = 68; AONGUI.Box(new Rect(rect.x, rect.y, rect.width, height_top), "", backgroundTop); } AONGUI.Label(new Rect(rect.x + 4, yGui + DefineAON.GUI_Y_Label, rect.width, DefineAON.GUI_Height_Label), title); yGui += 32f; if (flagsYaml == null) { return; } //Check key lock if (flagsYaml.CheckLockKey(lockKey)) { AONGUIBehaviour.AONGUI_ReDrawAll(); return; } var keys = flagsYaml.Keys; { //Add Key float xGui = rect.x + 4; AONGUI.Label(new Rect(xGui, yGui + DefineAON.GUI_Y_Label, 90, DefineAON.GUI_Height_Label), "Slug flag"); xGui += 94; AONGUI.TextField(new Rect(xGui, yGui + DefineAON.GUI_Y_TextField, 200, DefineAON.GUI_Height_TextField), NameAdd, (string text) => { NameAdd = text; }); xGui += 204; if (NameAdd.Length == 0) { } else { bool isUnique = true; foreach (string key in keys) { if (key == NameAdd) { isUnique = false; break; } } if (isUnique) { AONGUI.Button(new Rect(xGui, yGui + DefineAON.GUI_Y_Button, 40, DefineAON.GUI_Height_Button), "Add", () => { flagsYaml.Add(NameAdd, 0); NameAdd = ""; //Check clear cache comboBoxFlags if (_instance != null && _instance.flagsCurrent == flagsYaml) { _instance.ResetCombobox(); } }); } else { AONGUI.Label(new Rect(xGui, yGui + DefineAON.GUI_Y_Label, 200, DefineAON.GUI_Height_Label), "Slug should be unique"); } } yGui += 32f; } yGui += 16f; int count = 0; foreach (string key in keys) { bool lockKeySub = false; if (lockKey != null && count < lockKey.Length) { lockKeySub = true; } if (key != "") { KeyValueOnGUI(flagsYaml, key, ref yGui, rect, lockKeySub, resetList, count); } count++; } }
public void OnGUIDebug(TilesetAON tilesetAON) { if (!mShowDebug) { var rectBt = new Rect(8, Screen.height - 8 - DefineAON.GUI_Height_Button, 60, DefineAON.GUI_Height_Button); GameGui.SetRectIgnore(rectBt); AONGUI.Button(rectBt, "Debug", () => { mShowDebug = true; }); return; } float w = 380; float limitHeight = 350; Rect rect = new Rect(8, Screen.height - limitHeight - 8, w, limitHeight); AONGUI.Box(rect, ""); GameGui.SetRectIgnore(rect); string[] d = ScriptGui.StrFlagTarget; int current_target = (int)mTabFlagDebug; rect.x = rect.x + 8f; rect.width = rect.width - 16f; AONGUI.SelectionGrid(new Rect(rect.x, rect.y + 6, rect.width, 26), current_target, d, d.Length, tilesetAON.ListStyleGrid, (int next) => { mTabFlagDebug = (ScriptGui.FlagTarget)next; }); rect.y = rect.y + 32f; rect.height = rect.height - 64f; if (mTabFlagDebug == ScriptGui.FlagTarget.World) { FlagGui.OnGuiDebug(WorldFlag, rect, limitHeight); } else if (mTabFlagDebug == ScriptGui.FlagTarget.Map) { int mapIdx = AutoTileMap_Editor.Instance.MapIdxSelect; FlagGui.OnGuiDebug(MapFlag(mapIdx), rect, limitHeight); } else //mFlagDebug == ScriptGui.FlagTarget.Script { if (IsScriptMainRunning) { FlagGui.OnGuiDebug(ScriptMain.Flags, rect, limitHeight); } else { AONGUI.Label(new Rect(rect.x, rect.y + DefineAON.GUI_Y_Label, 150, DefineAON.GUI_Height_Label), "No script target"); } } float yGui = Screen.height - 36; float xGui = 12; { var rectBt = new Rect(xGui, yGui, 50, 24); AONGUI.Button(rectBt, "Hide", () => { mShowDebug = false; }); xGui += 54; } { var rectBt = new Rect(xGui, yGui, 50, 24); AONGUI.Button(rectBt, AutoTileMap_Editor.Instance.DayNight.Hour.ToString() + "h +1", () => { AutoTileMap_Editor.Instance.UpdateTime1Hour(); }); xGui += 54; } { var rectBt = new Rect(xGui, yGui, 50, 24); AONGUI.Button(rectBt, "Base", () => { AutoTileMap_Editor.Instance.NextBase(); }); xGui += 54; } { var rectBt = new Rect(xGui, yGui, 50, 24); AONGUI.Button(rectBt, "Skin", () => { AutoTileMap_Editor.Instance.NextSkin(); }); xGui += 54; } { var rectBt = new Rect(xGui, yGui, 50, 24); AONGUI.Button(rectBt, "Cos", () => { AutoTileMap_Editor.Instance.NextCostume(); }); xGui += 54; } { var rectBt = new Rect(xGui, yGui, 100, 24); AONGUI.Toggle(rectBt, !AutoTileMap_Editor.Instance.CamControler.canControl, " Lock cam", (bool b) => { AutoTileMap_Editor.Instance.CamControler.canControl = b; }); xGui += 104; } }
public void MapOnGUI(TilesetAON tilesetAON, AutoTileMapSerializeData d, AutoTileMap autoTileMap, AComponent_Button.OnClick closeDialog) { float W_ScopeList = 200; float yGui = 0f; Rect rectMenuLeft = new Rect(0, 0, W_ScopeList, Screen.height); AONGUI.Box(rectMenuLeft, "", tilesetAON.ListStyleBlack); { Rect rect = new Rect(0, 0, W_ScopeList, Screen.height); yGui = 4f; AONGUI.Box(rect, "", tilesetAON.ListStyleBlack); AONGUI.Button(new Rect(4, yGui, 45, 26), "Back", closeDialog); AONGUI.Label(new Rect(54, yGui, W_ScopeList - 54, 26), "Map edit"); yGui += 32f; OnGUIMenuLeft(tilesetAON, ref yGui, rectMenuLeft); } Rect rectContent = new Rect(W_ScopeList, 0, Screen.width - W_ScopeList, Screen.height); AONGUI.Box(rectContent, ""); yGui = 0f; if (mMenuLeft == EMenuLeft.General) { OnGuiGeneral(tilesetAON, autoTileMap, rectContent); } else if (mMenuLeft == EMenuLeft.FlagMap) { FlagGui.DisOnGUI(d.FlagMap, ref yGui, rectContent, null, tilesetAON.ListStyleBlack2, "Flag map edit :"); } else if (mMenuLeft == EMenuLeft.Action) { // OnGUITriggerList(tilesetAON, d, eSlotAonTypeObj.Warps, DefineAON.IdSlot_Warps, ref yGui, rectContent); if (d.ListFlagAction == null) { d.ListFlagAction = new List <FlagAction>(); } if (d.ListFlagAction.Count == 0) { d.ListFlagAction.Add(new FlagAction()); } d.ListFlagAction[0].Name = ""; d.ListFlagAction[0].Key = ""; d.ListFlagAction[0].Value = 0; Rect rect = new Rect(W_ScopeList, 0, Screen.width - W_ScopeList, Screen.height); bool isWaitUI = false; if (FlagAction.OnGUIFlagActionList(ref yGui, ref isWaitUI, rectContent, d.ListFlagAction, d.FlagMap, tilesetAON.ListStyleBlack2)) { return; } } else if (mMenuLeft == EMenuLeft.Warp) { OnGUITriggerList(tilesetAON, d, eSlotAonTypeObj.Warps, DefineAON.IdSlot_Warps, ref yGui, rectContent); } else if (mMenuLeft == EMenuLeft.NPC) { OnGUITriggerList(tilesetAON, d, eSlotAonTypeObj.Person, DefineAON.IdSlot_NPC, ref yGui, rectContent); } else if (mMenuLeft == EMenuLeft.Script) { OnGUITriggerList(tilesetAON, d, eSlotAonTypeObj.Script, DefineAON.IdSlot_Script, ref yGui, rectContent); } // float yGui = 0f; // bool isUpdateFlag = FlagGui.DisOnGUI( ref d.FlagMap, ref yGui, rect, null, tilesetAON.ListStyleBlack2, "Flag map edit :"); }
private void OnGUITriggerList(TilesetAON tilesetAON, AutoTileMapSerializeData d, eSlotAonTypeObj e, int idSlotTrigger, ref float yGui, Rect rect) { float W_ScopeList = 200; AONGUI.Label(new Rect(rect.x + 4, yGui + DefineAON.GUI_Y_Label, W_ScopeList, DefineAON.GUI_Height_Label), e.ToString() + " list :"); yGui += 32f; d.TriggerCountAt(e); var comboBoxTrigger = ComboBoxHelper.Instance.TypeObj(d, e); comboBoxTrigger.Rect.x = rect.x; comboBoxTrigger.Rect.y = yGui; comboBoxTrigger.Rect.width = W_ScopeList; comboBoxTrigger.Rect.height = 32f; comboBoxTrigger.SelectedItemIndex = currentIdxTrigger; comboBoxTrigger.Show(rect.height - yGui - 32f, "defause", true, false, (int idxTrigger) => { currentIdxTrigger = comboBoxTrigger.SelectedItemIndex; refTrigger = null; }); var autoTileMap = AutoTileMap_Editor.Instance; if (autoTileMap == null || autoTileMap.MapSelect != d) { return; } if (comboBoxTrigger.IsDropDownListVisible) { //Create new AONGUI.Button(new Rect(rect.x, rect.y + rect.height - 32f, W_ScopeList, DefineAON.GUI_Height_Button), "Create new " + e.ToString(), () => { autoTileMap.MapSelect.CreateNewTrigger(e); }); } Trigger trigger = d.GetTriggerByIdxRef(currentIdxTrigger, e); if (trigger == null) { return; } yGui = 4f; rect.x = rect.x + W_ScopeList + 10; if (string.IsNullOrEmpty(trigger.Name())) { AONGUI.Label(new Rect(rect.x, yGui, rect.width, 32), "Name: NULL"); } else { AONGUI.Label(new Rect(rect.x, yGui, rect.width, 32), "Name: " + trigger.Name()); } yGui += 32f; if (refTrigger == null) { refTrigger = new List <AutoTile>(); var triggerLink = d.TriggerLink; var tileMapWidth = autoTileMap.MapTileWidth; var tileMapHeight = autoTileMap.MapTileHeight; int layerTrigger = (int)eSlotAonTypeLayer.Trigger; for (int x = 0; x < tileMapWidth; x++) { for (int y = 0; y < tileMapHeight; y++) { var a = autoTileMap.GetAutoTile(x, y, layerTrigger); if (a == null) { continue; } if (a.Id < 0) { continue; } int idSlot = a.Id; if (idSlot != idSlotTrigger) { continue; } if (currentIdxTrigger != d.GetTriggerRef(x, y)) { continue; } refTrigger.Add(a); } } } AONGUI.Label(new Rect(rect.x, yGui, rect.width, 32), "Reference on map: " + refTrigger.Count); yGui += 32f; AONGUI.Label(new Rect(rect.x, yGui, rect.width, 32), "----Edit----"); yGui += 32f; if (e == eSlotAonTypeObj.Script) { yGui += 16f; AONGUI.Button(new Rect(rect.x, yGui, 100, DefineAON.GUI_Height_Label), "Edit", () => { tilesetAON.TriggerShowMoreInfo = trigger; }); } else { bool isShowMoreInfo = true; trigger.ShowGUI(new Rect(rect.x, yGui, rect.width, rect.y + rect.height - yGui), AutoTileMap_Editor.Instance, tilesetAON, ref isShowMoreInfo, null); } }
public void WorldOnGUI(TilesetAON tilesetAON, AutoTileMapData d, AComponent_Button.OnClick onCloseDialog) { // Rect rect Rect rectFull = new Rect(0, 0, Screen.width, Screen.height); AONGUI.Box(rectFull, ""); float W_ScopeList = 200; { Rect rect = new Rect(0, 0, W_ScopeList, Screen.height); float yGui = 4f; AONGUI.Box(rect, "", tilesetAON.ListStyleBlack); AONGUI.Button(new Rect(4, yGui, 45, 26), "Back", onCloseDialog); AONGUI.Label(new Rect(54, yGui, W_ScopeList - 54, 26), "World edit"); yGui += 32f; float w = (W_ScopeList) / 2; AONGUI.Button(new Rect(4, yGui, w - 8, 26), "Save", () => { string title = "Save world data ( not include map)"; FileBrowser.SaveFilePanel(title, title, Application.persistentDataPath, "worlddata.json", new string[] { "json" }, null, (bool canceled, string filePath) => { if (canceled) { return; } File.WriteAllText(filePath, d.GetDataWorld(false)); }); }); AONGUI.Button(new Rect(w + 4, yGui, w - 8, 26), "Load", () => { var title = "Load world data ( not include map)"; var path = Application.persistentDataPath + "/worlddata.json"; FileBrowser.OpenFilePanel(title, path, new string[] { "json" }, null, (bool canceled, string filePath) => { if (canceled) { return; } if (File.Exists(filePath)) { var data = File.ReadAllText(filePath); if (d.LoadDataWorld(data, false) == false) { InputFieldHelper.Instance.ShowNoti("Load error"); } } }); }); yGui += 4f; yGui += 32f; OnGUIMenuLeft(tilesetAON, ref yGui, new Rect(0, 0, W_ScopeList, rectFull.height)); } if (mMenuLeft == EMenuLeft.FlagWorld) { Rect rect = new Rect(W_ScopeList, 0, Screen.width - W_ScopeList, Screen.height); float yGui = 0f; FlagGui.DisOnGUI(d.FlagWorld, ref yGui, rect, AutoTileMapData.LockFlagWorld, tilesetAON.ListStyleBlack2, "Flag world edit :"); } else if (mMenuLeft == EMenuLeft.ActionWorld) { if (d.ListFlagAction == null) { d.ListFlagAction = new List <FlagAction>(); } if (d.ListFlagAction.Count == 0) { d.ListFlagAction.Add(new FlagAction()); } d.ListFlagAction[0].Name = ""; d.ListFlagAction[0].Key = ""; d.ListFlagAction[0].Value = 0; Rect rect = new Rect(W_ScopeList, 0, Screen.width - W_ScopeList, Screen.height); float yGui = 0f; bool isWaitUI = false; if (FlagAction.OnGUIFlagActionList(ref yGui, ref isWaitUI, rect, d.ListFlagAction, d.FlagWorld, tilesetAON.ListStyleBlack2)) { return; } } else if (mMenuLeft == EMenuLeft.Property) { Rect rect = new Rect(W_ScopeList, 0, Screen.width - W_ScopeList, Screen.height); PropertysGUI.Instance.OnGUI(d.Propertys, d.ListFlagAction, tilesetAON, rect); } else if (mMenuLeft == EMenuLeft.Package) { Rect rect = new Rect(W_ScopeList, 0, Screen.width - W_ScopeList, Screen.height); PackagesGUI.Instance.OnGUI(d.Packages, d.Propertys, d.ListFlagAction, tilesetAON, rect); } }
public void Show(float viewHeight, string hash, bool showSearch, bool forceShow, float xBoxBegin, float xBoxEnd, OnSelect onSelect) { // onSelect = null; if (forceShow) { Rect.y = Rect.y - Rect.height; // viewHeight += Rect.height; } else { viewHeight -= Rect.height; } GUIStyle StyleContent = ListStyleContent; mIsDropDownListVisible = (currentHash == hash); bool isDropDown = mIsDropDownListVisible || forceShow; // if(isDropDown && listContent.Length > 0){ // float contentHeightMax = UnitHeight * listContent.Length; // if(showSearch){ // contentHeightMax += 32f; // } // if(viewHeight > contentHeightMax){ // viewHeight = contentHeightMax; // } // } // bool isWillClose = false; if (forceShow == false) { AONGUI.AddOnGui((AComponent a) => { int controlID = GUIUtility.GetControlID(FocusType.Passive); switch (Event.current.GetTypeForControl(controlID)) { case EventType.MouseUp: { if (isDropDown) { float xBegin = xBoxBegin > 0 ? xBoxBegin : Rect.x; float xEnd = xBoxEnd > 0 ? xBoxEnd : Rect.x + Rect.width; float yEndContent = Rect.y + Rect.height + viewHeight; Vector2 posMouse = Event.current.mousePosition; if (posMouse.x < xBegin || posMouse.x > xEnd || posMouse.y < Rect.y || posMouse.y > yEndContent) { Close(); } /* * if( showSearch * && posMouse.y >= yEndContent - 32f * && posMouse.y <= yEndContent * && posMouse.x >= xBegin * && posMouse.x <= xEnd) { * //Click on Box Search And do not thing * }else if( posMouse.x >= xEnd - 16 * && posMouse.x <= xEnd * && posMouse.y >= Rect.y * && posMouse.y <= yEndContent) { * // Click on Scroll and do nothing * }else * { * isWillClose = true; * } */ } } break; } }); AONGUI.Button(new Rect(Rect.x, Rect.y, Rect.width, DefineAON.GUI_Height_Button), buttonContent, () => { if (currentHash == hash) { Close(); } else { if (lastComboBoxShow == this) { if (currentHash != hash) { currentHash = hash; } } else { if (lastComboBoxShow != null) { lastComboBoxShow.currentHash = ""; lastComboBoxShow.mIsDropDownListVisible = false; } if (mIsDropDownListVisible == false) { // Open mIsDropDownListVisible = true; currentHash = hash; lastComboBoxShow = this; } else { Close(); } } } }); } if (isDropDown) { if (xBoxBegin > 0) { Rect.x = xBoxBegin; } if (xBoxEnd > 0) { Rect.xMax = xBoxEnd; } if (listContent != null && listContent.Length > 0) { // int max_count = (int) ((viewHeight - 32) / UnitHeight); // if(listContent.Length > max_count){ // GUIContent[] listContent2 = new GUIContent[max_count]; // for (int i = 0; i < max_count; i++) // { // listContent2[i] = listContent[i]; // } // listContent = listContent2; // } // float unitHeight = StyleContent.CalcHeight(listContent[0], 1.0f); float contentHeight = UnitHeight * listContent.Length; // viewHeight -= Rect.height; { //Input Fillter AONGUI.Box(new Rect(Rect.x, Rect.y + Rect.height, Rect.width, viewHeight), "", ListStyleGrid); float heightSearch = 0; if (showSearch) //Search { if (!forceShow) { AONGUI.SetNextControlName("TextField"); } float yGui = Rect.y + Rect.height + viewHeight - DefineAON.GUI_Height_Button; AONGUI.TextField(new Rect(Rect.x, yGui, Rect.width - 50, 25), currentSearch, (string text) => { currentSearch = text.ToLower(); itemHightLight = -1; if (currentSearch != "") { for (int i = 0; i < listContent.Length; i++) { string t = listContent[i].text; if (!string.IsNullOrEmpty(t) && t.ToLower().IndexOf(currentSearch) >= 0) { itemHightLight = i; m_scrollPos.y = UnitHeight * itemHightLight;; break; } } } }); if (!forceShow) { AONGUI.FocusControl("TextField"); } AONGUI.Button(new Rect(Rect.x + Rect.width - 50, yGui, 25, 25), "<", KeyCode.LeftArrow, () => { if (currentSearch != "") { int lastHightlight = itemHightLight - 1; if (itemHightLight < 0 || itemHightLight >= listContent.Length) { lastHightlight = listContent.Length - 1; } itemHightLight = -1; for (int i = lastHightlight; i >= 0; i--) { string t = listContent[i].text; if (!string.IsNullOrEmpty(t) && t.ToLower().IndexOf(currentSearch) >= 0) { itemHightLight = i; m_scrollPos.y = UnitHeight * itemHightLight;; break; } } } }); AONGUI.Button(new Rect(Rect.x + Rect.width - 25, yGui, 25, 25), ">", KeyCode.RightArrow, () => { if (currentSearch != "") { int lastHightlight = itemHightLight + 1; if (lastHightlight < 0 || lastHightlight >= listContent.Length) { lastHightlight = 0; } itemHightLight = -1; for (int i = lastHightlight; i < listContent.Length; i++) { string t = listContent[i].text; if (!string.IsNullOrEmpty(t) && t.ToLower().IndexOf(currentSearch) >= 0) { itemHightLight = i; m_scrollPos.y = UnitHeight * itemHightLight;; break; } } } }); heightSearch = 32f; } if (!forceShow) { AONGUI.AddOnGui((AComponent a) => { if (itemHightLight != -1) { if (Event.current.isKey && Event.current.keyCode == KeyCode.DownArrow) { itemHightLight++; if (itemHightLight >= listContent.Length) { itemHightLight = 0; } m_scrollPos.y = UnitHeight * itemHightLight;; } if (Event.current.isKey && Event.current.keyCode == KeyCode.UpArrow) { itemHightLight--; if (itemHightLight < 0) { itemHightLight = listContent.Length - 1; } m_scrollPos.y = UnitHeight * itemHightLight;; } } else { if (Event.current.isKey && (Event.current.keyCode == KeyCode.DownArrow || Event.current.keyCode == KeyCode.UpArrow)) { itemHightLight = SelectedItemIndex; m_scrollPos.y = UnitHeight * itemHightLight;; } } }); } Rect view = new Rect(Rect.x, Rect.y + Rect.height, Rect.width, viewHeight - heightSearch); Rect listRect = new Rect(Rect.x, Rect.y + Rect.height, Rect.width, contentHeight); bool showScroll = listRect.height > view.height; if (showScroll) { listRect.width = Rect.width - 16f; // Optimal Grid AONGUI.AddOnGui((AComponent a) => { m_scrollPos = GUI.BeginScrollView(view, m_scrollPos, listRect, false, showSearch ? true : false); int pos_begin = (int)(m_scrollPos.y / UnitHeight); int max_count = (int)(view.height / UnitHeight) + 1; if (max_count + pos_begin > listContent.Length) { max_count = listContent.Length - pos_begin - 1; } GUIContent[] listContent2 = new GUIContent[max_count]; for (int i = 0; i < max_count; i++) { listContent2[i] = listContent[i + pos_begin]; } Rect listRect2 = listRect; listRect2.y = listRect.y + pos_begin * UnitHeight; listRect2.height = max_count * UnitHeight; var nextselect = GUI.SelectionGrid(listRect2, selectedItemIndex, listContent2, 1, StyleContent); if (nextselect != selectedItemIndex) { AONGUI.Target.Actions += () => { SelectedItemIndex = pos_begin + nextselect; Close(); onSelect(SelectedItemIndex); }; } // AONGUI.SelectionGrid(listRect2, selectedItemIndex, listContent2, 1, StyleContent, (int next) => { // SelectedItemIndex = next; // Close(); // onSelect(SelectedItemIndex); // }); // GUI.SelectionGrid(listRect, selectedItemIndex, listContent, 1, StyleContent); if (itemHightLight != -1) { float y = listRect.y + UnitHeight * itemHightLight; GUI.Box(new Rect(listRect.x, y, listRect.width, UnitHeight), "", ListStyleHightlight); if (Event.current.isKey && Event.current.keyCode == KeyCode.Return) { SelectedItemIndex = itemHightLight; AONGUI.Target.Actions += () => { SelectedItemIndex = itemHightLight; Close(); onSelect(SelectedItemIndex); }; } } GUI.EndScrollView(); }); } else { AONGUI.AddOnGui((AComponent a) => { var nextselect = GUI.SelectionGrid(listRect, selectedItemIndex, listContent, 1, StyleContent); if (nextselect != selectedItemIndex) { AONGUI.Target.Actions += () => { SelectedItemIndex = nextselect; Close(); onSelect(SelectedItemIndex); }; } if (itemHightLight != -1) { float y = listRect.y + UnitHeight * itemHightLight; GUI.Box(new Rect(listRect.x, y, listRect.width, UnitHeight), "", ListStyleHightlight); if (Event.current.isKey && Event.current.keyCode == KeyCode.Return) { SelectedItemIndex = itemHightLight; AONGUI.Target.Actions += () => { SelectedItemIndex = itemHightLight; Close(); onSelect(SelectedItemIndex); }; } } }); } } } else { // listContent is null // Rect view = new Rect(Rect.x, Rect.y + Rect.height, Rect.width, limitHeight - Rect.height); Rect view = new Rect(Rect.x, Rect.y + Rect.height, Rect.width, 32f); AONGUI.Box(view, "", ListStyleGrid); AONGUI.Label(view, "- Empty -", StyleContent); } } return; }
private bool OnGuiBot(SerializablePropertys data, List <FlagAction> listFlagAction, TilesetAON tilesetAON, Rect rect) { if (data == null) { return(false); } float yGui = rect.y + 4; float widthLeft = 200; AONGUI.Label(new Rect(rect.x + 4, yGui + DefineAON.GUI_Y_Label, widthLeft, DefineAON.GUI_Height_Label), "Edit property:"); yGui += 32f; { comboBoxSlug.UpdateListContent(data.AllKey); comboBoxSlug.Empty = "Not selected"; comboBoxSlug.SelectedItemIndex = slugIndext; comboBoxSlug.Rect.x = rect.x; comboBoxSlug.Rect.y = yGui; comboBoxSlug.Rect.width = widthLeft; comboBoxSlug.Rect.height = 32f; comboBoxSlug.Show(rect.height - yGui, "defause", true, false, (int next) => { slugIndext = next; }); } // if(comboBoxSlug.IsDropDownListVisible){ // return true; // } yGui = rect.y + 4; rect.x = rect.x + widthLeft + 4; if (slugIndext < 0 || slugIndext >= data.AllKey.Count) { return(true); } AONGUI.Button(new Rect(rect.x, yGui + DefineAON.GUI_Y_Button, 120, DefineAON.GUI_Height_Button), "Remove by slug", () => { data.Remove(slugIndext); }); SerializablePropertys.Property property = data.PropertyByIndex(slugIndext); AONGUI.Button(new Rect(rect.x + 130, yGui + DefineAON.GUI_Y_Button, 120, DefineAON.GUI_Height_Button), "Duplicate by slug", () => { var n = data.Copy(slugIndext); if (n >= 0) { slugIndext = n; } }); yGui += 32f; AONGUI.Label(new Rect(rect.x, yGui + DefineAON.GUI_Y_Label, 40, DefineAON.GUI_Height_Label), "Name"); AONGUI.TextField(new Rect(rect.x + 40, yGui + DefineAON.GUI_Y_TextField, widthLeft - 40, DefineAON.GUI_Height_TextField), property.Name, (string text) => { property.Name = text; }); yGui += 32f; AONGUI.Label(new Rect(rect.x, yGui + DefineAON.GUI_Y_Label, 40, DefineAON.GUI_Height_Label), "Des"); AONGUI.TextField(new Rect(rect.x + 40, yGui + DefineAON.GUI_Y_TextField, widthLeft - 40, DefineAON.GUI_Height_TextField), property.Des, (string text) => { property.Des = text; }); yGui += 32f; string[] strType = SerializablePropertys.StrEType; AONGUI.SelectionGrid(new Rect(rect.x, yGui, rect.width, 24f), (int)property._Type, strType, strType.Length, tilesetAON.ListStyleGrid, (int next) => { var tNext = (SerializablePropertys.EType)next; if (tNext != property._Type) { property._Type = tNext; } }); yGui += 32f; // if(property.IsItem){ // property.StackInBag = GUI.Toggle(new Rect( rect.x, yGui + DefineAON.GUI_Y_Label, widthLeft, DefineAON.GUI_Height_Label ), property.StackInBag, "Can Stack in bag"); // yGui += 32f; // } // property.CanEquip = GUI.Toggle(new Rect( rect.x, yGui + DefineAON.GUI_Y_Label, widthLeft, DefineAON.GUI_Height_Label ), property.CanEquip, " Can Equip"); if (property.IsOutfit) { // float xGui = rect.x + widthLeft + 4; float xGui = rect.x; AONGUI.Label(new Rect(xGui, yGui + DefineAON.GUI_Y_Label, 60, DefineAON.GUI_Height_Label), "Item :"); xGui += 60; string[] str = AutoTileMap_Editor.Instance.ItemCharData.StrItemList; var combobox = ComboBoxHelper.Instance.StringN(str); var hash = "item"; int currentItem = ComboBoxHelper.Instance.IndextOfStringN(str, property.RefSlug); if (currentItem == -1) { if (property.RefSlug != null && property.RefSlug != "") { combobox.Empty = property.RefSlug + " (not found)"; } else { combobox.Empty = "NULL"; } } combobox.SelectedItemIndex = currentItem; combobox.Rect.x = xGui; combobox.Rect.y = yGui; combobox.Rect.width = widthLeft; combobox.Rect.height = 32f; float limitHeight = 32f * 6; combobox.Show(limitHeight, hash, (int nextItem) => { property.RefSlug = str[nextItem]; }); if (combobox.IsDropDownWithHash(hash)) { yGui += limitHeight; return(false); } yGui += 32f; } // property.CanUsing = GUI.Toggle(new Rect( rect.x, yGui + DefineAON.GUI_Y_Label, widthLeft, DefineAON.GUI_Height_Label ), property.CanUsing, " Can Using"); if (property.IsItem) { // float xGui = rect.x + widthLeft + 4; float xGui = rect.x; AONGUI.Label(new Rect(xGui, yGui + DefineAON.GUI_Y_Label, 60, DefineAON.GUI_Height_Label), "Action :"); xGui += 60; var combobox = ComboBoxHelper.Instance.FlagAction(listFlagAction); var hash = "property"; int currentFlagAction = FlagAction.IndextFlagAction(listFlagAction, property.ActionUsing); if (currentFlagAction == -1) { if (property.ActionUsing != null && property.ActionUsing != "") { combobox.Empty = property.ActionUsing + " (not found)"; } else { combobox.Empty = "NULL"; } } combobox.SelectedItemIndex = currentFlagAction; combobox.Rect.x = xGui; combobox.Rect.y = yGui; combobox.Rect.width = widthLeft; combobox.Rect.height = 32f; float limitHeight = 32f * 6; combobox.Show(limitHeight, hash, (int nextAction) => { property.ActionUsing = listFlagAction[nextAction].Name; }); if (combobox.IsDropDownWithHash(hash)) { yGui += limitHeight; return(false); } yGui += 32f; } // property.Consume = GUI.Toggle(new Rect( rect.x, yGui + DefineAON.GUI_Y_Label, widthLeft, DefineAON.GUI_Height_Label ), property.Consume, "Consumable"); // yGui += 32f; if (property.IsPet) { AONGUI.Label(new Rect(rect.x, yGui + DefineAON.GUI_Y_Label, 40, DefineAON.GUI_Height_Label), "Pet"); AONGUI.TextField(new Rect(rect.x + 40, yGui + DefineAON.GUI_Y_TextField, widthLeft - 40, DefineAON.GUI_Height_TextField), property.RefSlug, (string text) => { property.RefSlug = text; }); AONGUI.Button(new Rect(rect.x + widthLeft + 10, yGui + DefineAON.GUI_Y_TextField, 40, DefineAON.GUI_Height_TextField), "Pick", () => { InputFieldHelper.Instance.ShowPickModel((string topic, string pet) => { Debug.Log(topic + "/" + pet); property.RefSlug = topic + "/" + pet; InputFieldHelper.Instance.HidePickModel(); }); }); yGui += 32f; } if (property.IsItem || property.IsCertificates) { AONGUI.Label(new Rect(rect.x, yGui + DefineAON.GUI_Y_Label, 40, DefineAON.GUI_Height_Label), "Icon"); AONGUI.TextField(new Rect(rect.x + 40, yGui + DefineAON.GUI_Y_TextField, widthLeft - 40, DefineAON.GUI_Height_TextField), property.RefIcon, (string text) => { property.RefIcon = text; }); AONGUI.Button(new Rect(rect.x + widthLeft + 10, yGui + DefineAON.GUI_Y_TextField, 40, DefineAON.GUI_Height_TextField), "Pick", () => { InputFieldHelper.Instance.ShowPickIcon((string topic, string icon) => { // Debug.Log(topic + "/" + icon); property.RefIcon = topic + "/" + icon; InputFieldHelper.Instance.HidePickIcon(); }); }); yGui += 32f; } return(false); }
private bool OnGuiBot(SerializablePackages packages, SerializablePropertys propertys, List <FlagAction> listFlagAction, TilesetAON tilesetAON, Rect rect) { if (packages == null) { return(false); } float yGui = rect.y + 4; float widthLeft = 250; AONGUI.Label(new Rect(rect.x + 4, yGui + DefineAON.GUI_Y_Label, widthLeft, DefineAON.GUI_Height_Label), "Edit package:"); yGui += 32f; { comboBoxSlug.UpdateListContent(packages.AllKey); comboBoxSlug.Empty = "Not selected"; comboBoxSlug.SelectedItemIndex = slugIndex; comboBoxSlug.Rect.x = rect.x; comboBoxSlug.Rect.y = yGui; comboBoxSlug.Rect.width = widthLeft; comboBoxSlug.Rect.height = 32f; comboBoxSlug.Show(rect.height - yGui, "defause", true, false, (int next) => { slugIndex = next; }); } // if(comboBoxSlug.IsDropDownListVisible){ // return true; // } yGui = rect.y + 4; rect.x = rect.x + widthLeft + 4; if (slugIndex < 0 || slugIndex >= packages.Count) { return(true); } AONGUI.Button(new Rect(rect.x, yGui + DefineAON.GUI_Y_Button, 120, DefineAON.GUI_Height_Button), "Remove by slug", () => { packages.Remove(slugIndex); slugIndex = -1; }); SerializablePackages.Package package = packages.PackageByIndex(slugIndex); AONGUI.Button(new Rect(rect.x + 130, yGui + DefineAON.GUI_Y_Button, 120, DefineAON.GUI_Height_Button), "Duplicate by slug", () => { var n = packages.Copy(slugIndex); if (n >= 0) { slugIndex = n; } }); AONGUI.Button(new Rect(rect.x + 260, yGui + DefineAON.GUI_Y_Button, 100, DefineAON.GUI_Height_Label), "Add all Pets", () => { _addAllPets(package, propertys); }); yGui += 32f; AONGUI.Label(new Rect(rect.x, yGui + DefineAON.GUI_Y_Label, 40, DefineAON.GUI_Height_Label), "Name"); AONGUI.TextField(new Rect(rect.x + 40, yGui + DefineAON.GUI_Y_TextField, widthLeft - 40, DefineAON.GUI_Height_TextField), package.Name, (string text) => { package.Name = text; }); yGui += 32f; AONGUI.Label(new Rect(rect.x, yGui + DefineAON.GUI_Y_Label, 40, DefineAON.GUI_Height_Label), "Des"); AONGUI.TextField(new Rect(rect.x + 40, yGui + DefineAON.GUI_Y_TextField, widthLeft - 40, DefineAON.GUI_Height_TextField), package.Des, (string text) => { package.Des = text; }); yGui += 32f; if (propertys == null || propertys.Count <= 0) { AONGUI.Label(new Rect(rect.x, yGui + DefineAON.GUI_Y_Label, widthLeft, DefineAON.GUI_Height_Label), "Propertys is empty"); return(false); } AONGUI.Label(new Rect(rect.x, yGui + DefineAON.GUI_Y_Label, widthLeft, DefineAON.GUI_Height_Label), "Propertys list:"); yGui += 32f; { comboBoxItem.UpdateListContent(package.data.Keys); comboBoxItem.Empty = "Not selected"; comboBoxItem.SelectedItemIndex = itemIndex; comboBoxItem.Rect.x = rect.x; comboBoxItem.Rect.y = yGui; comboBoxItem.Rect.width = widthLeft; comboBoxItem.Rect.height = 32f; comboBoxItem.Show(rect.height - yGui, "defause", true, true, ( int next) => { itemIndex = next; }); } AONGUI.Button(new Rect(rect.x + widthLeft + 10, yGui + DefineAON.GUI_Y_Button, 30, DefineAON.GUI_Height_Label), " + ", () => { if (itemIndex >= 0 && itemIndex < propertys.Count) { package.AddProperty(propertys.SlugByIndex(itemIndex)); } else { package.AddProperty(propertys.SlugByIndex(0)); } }); if (itemIndex < 0) { return(false); } AONGUI.Button(new Rect(rect.x + widthLeft + 50, yGui + DefineAON.GUI_Y_Button, 30, DefineAON.GUI_Height_Label), " - ", () => { package.Remove(itemIndex); }); if (package.data.Count == 0) { return(false); } if (itemIndex >= package.data.Count) { itemIndex = package.data.Count - 1; return(false); } rect.x = rect.x + widthLeft + 10; yGui += 32f; string slugProperty = package.data[itemIndex].property; { // Pick Property bool isWaitUI = false; PropertysGUI.Instance.PickSlugItem(slugIndex.ToString(), propertys, slugProperty, rect.x, yGui, widthLeft, ref yGui, ref isWaitUI, (string slugPropertyPick) => { package.data[itemIndex].property = slugPropertyPick; package.data.ResetKeys(); }); yGui += 32f; } AONGUI.Label(new Rect(rect.x, yGui + DefineAON.GUI_Y_Label, widthLeft, DefineAON.GUI_Height_Label), "Pay by:"); yGui += 32f; SerializablePackages.PayBy payBy = package.data[itemIndex].payBy; AONGUI.Label(new Rect(rect.x, yGui + DefineAON.GUI_Y_Label, 100, DefineAON.GUI_Height_Label), "Coin"); AONGUI.TextField(new Rect(rect.x + 100, yGui + DefineAON.GUI_Y_Label, widthLeft - 100, DefineAON.GUI_Height_Label), payBy.coin.ToString(), (string text) => { payBy.coin = UtilsAON.StrToIntDef(text); }); yGui += 32f; return(false); }
public static bool OnGUIFlagActionList(ref float yGui, ref bool waitUI, Rect rect, List <FlagAction> flagAction, Flags flagsYaml, GUIStyle backgroundTop) { if (backgroundTop != null) { float height_top = 68; AONGUI.Box(new Rect(rect.x, rect.y, rect.width, height_top), "", backgroundTop); } AONGUI.Label(new Rect(rect.x + 4, yGui + DefineAON.GUI_Y_Label, rect.width, DefineAON.GUI_Height_Label), "Action flag edit :"); yGui += 32f; { //Add Key float xGui = rect.x + 4; AONGUI.Label(new Rect(xGui, yGui + DefineAON.GUI_Y_Label, 90, DefineAON.GUI_Height_Label), "Slug action"); xGui += 94; AONGUI.TextField(new Rect(xGui, yGui + DefineAON.GUI_Y_TextField, 200, DefineAON.GUI_Height_TextField), NameAdd, (string text) => { NameAdd = text; }); xGui += 204; if (NameAdd.Length == 0) { } else { bool isUnique = (IndextFlagAction(flagAction, NameAdd) == -1); if (isUnique) { AONGUI.Button(new Rect(xGui, yGui + DefineAON.GUI_Y_Button, 40, DefineAON.GUI_Height_Button), "Add", () => { flagAction.Add(new FlagAction() { Name = NameAdd }); NameAdd = ""; }); } else { AONGUI.Label(new Rect(xGui, yGui + DefineAON.GUI_Y_Label, 200, DefineAON.GUI_Height_Label), "Slug should be unique"); } } yGui += 32f; } float size_sub_remove = 70; float size_next = 120; float size_o = 80; float size_v = 50; float size_text = (rect.width - size_sub_remove - size_v - size_o - size_next - 8) / 2; for (int k = 0; k < flagAction.Count; k++) { if (k == 0) { yGui += 32f; continue; } float xGui = rect.x + 4; FlagAction f = flagAction[k]; /* * if(k > 0){ * var name_next = GUI.TextField(new Rect(xGui, yGui + DefineAON.GUI_Y_TextField, size_text - 4, DefineAON.GUI_Height_TextField), f.Name, 25); * if(name_next != f.Name){ * f.Name = name_next; * return true; * } * }else{ * GUI.Label(new Rect(xGui, yGui + DefineAON.GUI_Y_TextField, size_text - 4, DefineAON.GUI_Height_TextField), f.Name); * } */ if (k == 1) { AONGUI.Label(new Rect(xGui, yGui - 25, size_next, 24), "Slug:"); } AONGUI.Label(new Rect(xGui, yGui + DefineAON.GUI_Y_TextField, size_text - 4, DefineAON.GUI_Height_TextField), f.Name); xGui += size_text; if (k == 1) { AONGUI.Label(new Rect(xGui, yGui - 25, size_next, 24), "Flag:"); } { var comboBoxFlags = FlagGui.Instance.UpdateFlagsData(flagsYaml, f.Key); int index_key = FlagGui.Instance.IndexOfKey(f.Key); comboBoxFlags.SelectedItemIndex = index_key; comboBoxFlags.Rect.x = xGui; comboBoxFlags.Rect.y = yGui; comboBoxFlags.Rect.width = size_text - 4; comboBoxFlags.Rect.height = 32f; // float limitHeight = rect.height - yGui - 32; float limitHeight = 32 * 6f; comboBoxFlags.Show(limitHeight, k.ToString(), (int flagNext) => { f.Key = FlagGui.Instance.KeyFromIndex(flagNext); }); if (comboBoxFlags.IsDropDownWithHash(k.ToString())) { yGui += limitHeight; waitUI = true; return(false); } } xGui += size_text; { //Operation int current = f.Operation; var comboBoxOperation = ComboBoxHelper.Instance.Operation(); comboBoxOperation.SelectedItemIndex = current; comboBoxOperation.Rect.x = xGui; comboBoxOperation.Rect.y = yGui; comboBoxOperation.Rect.width = size_o - 4; comboBoxOperation.Rect.height = 32f; float limitHeight = 32f * comboBoxOperation.ListContent.Length; comboBoxOperation.Show(limitHeight, k.ToString(), false, (int next) => { f.Operation = next; }); if (comboBoxOperation.IsDropDownWithHash(k.ToString())) { yGui += limitHeight; waitUI = true; return(false); } } float xGuiOperation = xGui; xGui += size_o; bool isHasInputValue = f.Operation < (int)AON.RpgMapEditor.ScriptGui.EOperation.Add_A_B; { if (isHasInputValue) { AONGUI.TextField(new Rect(xGui, yGui + DefineAON.GUI_Y_TextField, size_v - 10, DefineAON.GUI_Height_TextField), f.Value.ToString(), 25, (string text) => { f.Value = UtilsAON.StrToIntDef(text); }); } xGui += size_v; { //Next ( add) Action if (k == 1) { AONGUI.Label(new Rect(xGui + 10, yGui - 25, size_next, 24), "Add action:"); } var combobox = ComboBoxHelper.Instance.FlagAction(flagAction); var hash = k.ToString(); int currentFlagAction = FlagAction.IndextFlagAction(flagAction, f.Next); if (currentFlagAction == -1) { if (f.Next != null && f.Next != "") { combobox.Empty = f.Next + " (not found)"; } else { combobox.Empty = "NULL"; } } combobox.SelectedItemIndex = currentFlagAction; combobox.Rect.x = xGui + 10; combobox.Rect.y = yGui + 2; combobox.Rect.width = size_next - 20; combobox.Rect.height = 32f; float limitHeight = 32f * 6; combobox.Show(limitHeight, hash, (int nextAction) => { f.Next = flagAction[nextAction].Name; }); if (combobox.IsDropDownWithHash(hash)) { yGui += limitHeight; waitUI = true; return(false); } xGui += size_next; } AONGUI.Button(new Rect(xGui, yGui + DefineAON.GUI_Y_Button, size_sub_remove - 4, DefineAON.GUI_Height_Button), "Remove", () => { flagAction.RemoveAt(k); }); } /* * xGui += size_sub_e; * if(GUI.Button( new Rect(xGui, yGui + DefineAON.GUI_Y_Button, size_sub_e - 4, DefineAON.GUI_Height_Button), " + ")){ * FlagAction.Insert(k + 1, new FlagAction()); * return true; * } */ if (!isHasInputValue) { yGui += 32f; // float size_ab = (rect.x + rect.width - xGuiOperation - size_sub_remove) / 2; float size_ab = size_o + size_v; xGui = xGuiOperation; AONGUI.Label(new Rect(xGui - size_text, yGui, size_text, DefineAON.GUI_Height_Label), "= " + AON.RpgMapEditor.ScriptGui.StrEOperation[f.Operation]); AONGUI.Label(new Rect(xGui - 25, yGui, 20, DefineAON.GUI_Height_Label), "a ="); { string hash = "a" + k; var comboBoxFlags = FlagGui.Instance.UpdateFlagsData(flagsYaml, f.KeyA); int index_a = FlagGui.Instance.IndexOfKey(f.KeyA); comboBoxFlags.SelectedItemIndex = index_a; comboBoxFlags.Rect.x = xGui; comboBoxFlags.Rect.y = yGui; comboBoxFlags.Rect.width = size_ab; comboBoxFlags.Rect.height = 32f; // float limitHeight = rect.height - yGui - 32; float limitHeight = 32 * 6f; comboBoxFlags.Show(limitHeight, hash, (int flagNext) => { f.KeyA = FlagGui.Instance.KeyFromIndex(flagNext); }); if (comboBoxFlags.IsDropDownWithHash(hash)) { yGui += limitHeight; waitUI = true; return(false); } } // xGui += size_ab; yGui += 32f; AONGUI.Label(new Rect(xGui - 25, yGui, 20, DefineAON.GUI_Height_Label), "b = "); { string hash = "b" + k; var comboBoxFlags = FlagGui.Instance.UpdateFlagsData(flagsYaml, f.KeyB); int index_b = FlagGui.Instance.IndexOfKey(f.KeyB); comboBoxFlags.SelectedItemIndex = index_b; comboBoxFlags.Rect.x = xGui; comboBoxFlags.Rect.y = yGui; comboBoxFlags.Rect.width = size_ab; comboBoxFlags.Rect.height = 32f; // float limitHeight = rect.height - yGui - 32; float limitHeight = 32 * 6f; comboBoxFlags.Show(limitHeight, hash, (int flagNext) => { f.KeyB = FlagGui.Instance.KeyFromIndex(flagNext); }); if (comboBoxFlags.IsDropDownWithHash(hash)) { yGui += limitHeight; waitUI = true; return(false); } // var if_a_next = GUI.TextField(new Rect(rect.x + xGui, yGui + 32 - heighTextField, _w, heighTextField), if_a, 25); } yGui += 32f; yGui += 16f; } else { yGui += 32f; } } return(false); }