2019-08-29 19:17:35 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using SanAndreasUnity.Importing.GXT;
|
|
|
|
|
using SanAndreasUnity.Utilities;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace SanAndreasUnity.UI
|
|
|
|
|
{
|
|
|
|
|
class GXTWindow : PauseMenuWindow
|
|
|
|
|
{
|
|
|
|
|
private Vector2 _tableNameScrollPos;
|
|
|
|
|
private Vector2 _crcScrollPos;
|
|
|
|
|
private const float WindowWidth = 600;
|
|
|
|
|
private const float WindowHeight = 400;
|
|
|
|
|
private Int32? curCrc = null;
|
|
|
|
|
|
|
|
|
|
private List<Int32> crcList = new List<int>();
|
|
|
|
|
private GUIStyle _gxtTextAreaStyle;
|
|
|
|
|
|
|
|
|
|
GXTWindow()
|
|
|
|
|
{
|
|
|
|
|
//this will use as menu item name as well as window title
|
2019-08-29 20:22:22 +00:00
|
|
|
|
this.windowName = "GXT Viewer";
|
2019-08-29 19:17:35 +00:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SetUpGxtTextAreaStyle()
|
|
|
|
|
{
|
|
|
|
|
_gxtTextAreaStyle = new GUIStyle();
|
|
|
|
|
_gxtTextAreaStyle.wordWrap = true;
|
|
|
|
|
_gxtTextAreaStyle.normal.textColor = Color.white;
|
|
|
|
|
_gxtTextAreaStyle.padding = new RectOffset(20, 20, 10, 5);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Start()
|
|
|
|
|
{
|
|
|
|
|
this.RegisterButtonInPauseMenu();
|
|
|
|
|
this.windowRect = Utilities.GUIUtils.GetCenteredRect(new Vector2(WindowWidth, WindowHeight));
|
|
|
|
|
SetUpGxtTextAreaStyle();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private int m_currentPageNumber = 1;
|
|
|
|
|
private int numCrcPerPage = 40;
|
|
|
|
|
protected override void OnWindowGUI()
|
|
|
|
|
{
|
|
|
|
|
base.OnWindowGUI();
|
2019-10-06 19:34:41 +00:00
|
|
|
|
|
|
|
|
|
if (null == GXT.Current)
|
|
|
|
|
{
|
|
|
|
|
GUILayout.Label("GXT not loaded");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-29 19:17:35 +00:00
|
|
|
|
GUILayout.BeginHorizontal();
|
|
|
|
|
|
|
|
|
|
#region TableName
|
|
|
|
|
GUILayout.BeginVertical(GUILayout.Width(WindowWidth / 3));
|
|
|
|
|
GUILayout.Label("TableName");
|
|
|
|
|
_tableNameScrollPos = GUILayout.BeginScrollView(_tableNameScrollPos);
|
2019-10-06 19:29:03 +00:00
|
|
|
|
foreach (var gxtSubTableName in GXT.Current.SubTableNames)
|
2019-08-29 19:17:35 +00:00
|
|
|
|
{
|
|
|
|
|
if (GUILayout.Button(gxtSubTableName))
|
|
|
|
|
{
|
2019-10-06 19:29:03 +00:00
|
|
|
|
crcList = GXT.Current.TableEntryNameDict[gxtSubTableName];
|
2019-08-29 19:17:35 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
GUILayout.EndScrollView();
|
|
|
|
|
GUILayout.EndVertical();
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region CRC
|
|
|
|
|
GUILayout.BeginVertical(GUILayout.Width(WindowWidth / 3));
|
|
|
|
|
GUILayout.Label("CRC");
|
|
|
|
|
if (crcList.Count > numCrcPerPage) //only show pages when we really need
|
|
|
|
|
{
|
|
|
|
|
m_currentPageNumber = GUIUtils.DrawPagedViewNumbers(GUILayoutUtility.GetRect(WindowWidth/3,20),
|
|
|
|
|
m_currentPageNumber, crcList.Count, numCrcPerPage);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_crcScrollPos = GUILayout.BeginScrollView(_crcScrollPos);
|
|
|
|
|
|
|
|
|
|
foreach (var crc in crcList.Skip((m_currentPageNumber-1)*numCrcPerPage).Take(numCrcPerPage))
|
|
|
|
|
{
|
|
|
|
|
if (GUILayout.Button(crc.ToString()))
|
|
|
|
|
{
|
|
|
|
|
curCrc = crc;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
GUILayout.EndScrollView();
|
|
|
|
|
GUILayout.EndVertical();
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
GUILayout.BeginVertical(GUILayout.Width(WindowWidth / 3));
|
|
|
|
|
GUILayout.Label("text");
|
|
|
|
|
if (curCrc.HasValue)
|
|
|
|
|
{
|
|
|
|
|
|
2019-10-06 19:29:03 +00:00
|
|
|
|
GUILayout.TextArea(GXT.Current.EntryNameWordDict[curCrc.Value], _gxtTextAreaStyle);
|
2019-08-29 19:17:35 +00:00
|
|
|
|
}
|
|
|
|
|
GUILayout.EndHorizontal();
|
|
|
|
|
GUILayout.EndVertical();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|