diff --git a/Assets/Prefabs/UI/PGD.meta b/Assets/Prefabs/UI/PGD.meta new file mode 100644 index 00000000..b609a386 --- /dev/null +++ b/Assets/Prefabs/UI/PGD.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f1baada0d48e97d4caba5e676c74036a +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/Prefabs/UI/PRF_UI_CalendarItem.prefab b/Assets/Resources/Prefabs/UI/PRF_UI_CalendarItem.prefab new file mode 100644 index 00000000..04f00437 --- /dev/null +++ b/Assets/Resources/Prefabs/UI/PRF_UI_CalendarItem.prefab @@ -0,0 +1,442 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &956277598518386385 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 350622071464353800} + - component: {fileID: 3666807232690463195} + - component: {fileID: 5596363837942949343} + m_Layer: 5 + m_Name: SelectUI + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &350622071464353800 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 956277598518386385} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 5663509972648161664} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 30, y: 30} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &3666807232690463195 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 956277598518386385} + m_CullTransparentMesh: 1 +--- !u!114 &5596363837942949343 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 956277598518386385} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.043137275, g: 0.6195913, b: 0.8156863, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 21300000, guid: be0c90cd4ad68df469abdb1b6aec3e12, type: 3} + m_Type: 0 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!1 &2902962825967427172 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 6520105944163928002} + - component: {fileID: 5210010463140993914} + - component: {fileID: 3017080449125643136} + m_Layer: 5 + m_Name: TodayUI + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &6520105944163928002 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2902962825967427172} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 5663509972648161664} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 30, y: 30} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &5210010463140993914 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2902962825967427172} + m_CullTransparentMesh: 1 +--- !u!114 &3017080449125643136 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2902962825967427172} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.043137256, g: 0.34117648, b: 0.8156863, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 21300000, guid: be0c90cd4ad68df469abdb1b6aec3e12, type: 3} + m_Type: 0 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!1 &4341999869640149865 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 5663509972648161664} + - component: {fileID: 8570022658130637124} + - component: {fileID: 1647909120811987127} + m_Layer: 5 + m_Name: PRF_UI_CalendarItem + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &5663509972648161664 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4341999869640149865} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 5982924998747772425} + - {fileID: 350622071464353800} + - {fileID: 6520105944163928002} + - {fileID: 3971906318255557200} + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 30, y: 30} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &8570022658130637124 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4341999869640149865} + m_CullTransparentMesh: 1 +--- !u!114 &1647909120811987127 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4341999869640149865} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 82f43be8f5583ee4c8d6f3ef1b8bb308, type: 3} + m_Name: + m_EditorClassIdentifier: + HoverUI: {fileID: 0} + SelectUI: {fileID: 0} + TodayUI: {fileID: 0} + Text_Day: {fileID: 0} +--- !u!1 &5206417122210567764 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 5982924998747772425} + - component: {fileID: 3126620628418126379} + - component: {fileID: 1106112664917321319} + m_Layer: 5 + m_Name: HoverUI + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &5982924998747772425 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5206417122210567764} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 5663509972648161664} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 30, y: 30} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &3126620628418126379 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5206417122210567764} + m_CullTransparentMesh: 1 +--- !u!114 &1106112664917321319 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5206417122210567764} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.9490197, g: 0.9490197, b: 0.9490197, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 21300000, guid: be0c90cd4ad68df469abdb1b6aec3e12, type: 3} + m_Type: 0 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!1 &5325260341381955549 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 3971906318255557200} + - component: {fileID: 7842981886742081832} + - component: {fileID: 1485027349162457672} + - component: {fileID: 6802495630742468521} + m_Layer: 5 + m_Name: Text_Day + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &3971906318255557200 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5325260341381955549} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 5663509972648161664} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &7842981886742081832 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5325260341381955549} + m_CullTransparentMesh: 1 +--- !u!114 &1485027349162457672 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5325260341381955549} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_text: 30 + m_isRightToLeft: 0 + m_fontAsset: {fileID: 11400000, guid: 9a2c7e704ad3e62438526dc8aecaeb56, type: 2} + m_sharedMaterial: {fileID: 682561501981441939, guid: 9a2c7e704ad3e62438526dc8aecaeb56, + type: 2} + m_fontSharedMaterials: [] + m_fontMaterial: {fileID: 0} + m_fontMaterials: [] + m_fontColor32: + serializedVersion: 2 + rgba: 4294967295 + m_fontColor: {r: 1, g: 1, b: 1, a: 1} + m_enableVertexGradient: 0 + m_colorMode: 3 + m_fontColorGradient: + topLeft: {r: 1, g: 1, b: 1, a: 1} + topRight: {r: 1, g: 1, b: 1, a: 1} + bottomLeft: {r: 1, g: 1, b: 1, a: 1} + bottomRight: {r: 1, g: 1, b: 1, a: 1} + m_fontColorGradientPreset: {fileID: 0} + m_spriteAsset: {fileID: 0} + m_tintAllSprites: 0 + m_StyleSheet: {fileID: 0} + m_TextStyleHashCode: -1183493901 + m_overrideHtmlColors: 0 + m_faceColor: + serializedVersion: 2 + rgba: 4294967295 + m_fontSize: 15 + m_fontSizeBase: 15 + m_fontWeight: 400 + m_enableAutoSizing: 0 + m_fontSizeMin: 18 + m_fontSizeMax: 72 + m_fontStyle: 0 + m_HorizontalAlignment: 2 + m_VerticalAlignment: 512 + m_textAlignment: 65535 + m_characterSpacing: 0 + m_wordSpacing: 0 + m_lineSpacing: 0 + m_lineSpacingMax: 0 + m_paragraphSpacing: 0 + m_charWidthMaxAdj: 0 + m_enableWordWrapping: 1 + m_wordWrappingRatios: 0.4 + m_overflowMode: 0 + m_linkedTextComponent: {fileID: 0} + parentLinkedComponent: {fileID: 0} + m_enableKerning: 1 + m_enableExtraPadding: 0 + checkPaddingRequired: 0 + m_isRichText: 1 + m_parseCtrlCharacters: 1 + m_isOrthographic: 1 + m_isCullingEnabled: 0 + m_horizontalMapping: 0 + m_verticalMapping: 0 + m_uvLineOffset: 0 + m_geometrySortingOrder: 0 + m_IsTextObjectScaleStatic: 0 + m_VertexBufferAutoSizeReduction: 0 + m_useMaxVisibleDescender: 1 + m_pageToDisplay: 1 + m_margin: {x: 0, y: 0, z: 0, w: 0} + m_isUsingLegacyAnimationComponent: 0 + m_isVolumetricText: 0 + m_hasFontAssetChanged: 0 + m_baseMaterial: {fileID: 0} + m_maskOffset: {x: 0, y: 0, z: 0, w: 0} +--- !u!114 &6802495630742468521 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5325260341381955549} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3} + m_Name: + m_EditorClassIdentifier: + m_HorizontalFit: 2 + m_VerticalFit: 2 diff --git a/Assets/Resources/Prefabs/UI/PRF_UI_CalendarItem.prefab.meta b/Assets/Resources/Prefabs/UI/PRF_UI_CalendarItem.prefab.meta new file mode 100644 index 00000000..bd6a6e2e --- /dev/null +++ b/Assets/Resources/Prefabs/UI/PRF_UI_CalendarItem.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: e0e30dbfb835e694e81159517a269cf7 +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/PGD.meta b/Assets/Scripts/PGD.meta new file mode 100644 index 00000000..ce17ac56 --- /dev/null +++ b/Assets/Scripts/PGD.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c97945acc1902454baa9516736c26f50 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/PGD/UI_Calendar.cs b/Assets/Scripts/PGD/UI_Calendar.cs new file mode 100644 index 00000000..79e6995c --- /dev/null +++ b/Assets/Scripts/PGD/UI_Calendar.cs @@ -0,0 +1,139 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using TMPro; +using Unity.VisualScripting; +using UnityEngine; +using UnityEngine.UI; +using WI; + +public class UI_Calendar : UIBase +{ + public List calendarItemList = new List(); + public GameObject prefab_calendarItem; + public RectTransform Text_Sunday; + public RectTransform Text_Monday; + public RectTransform ItemRoot; + public TextMeshProUGUI Text_Day; + public Button Button_PrevMonth; + public Button Button_NextMonth; + + private const int totalItemNum = 42; + + private DateTime originDateTime; + private DateTime curDateTime; + + private TextMeshProUGUI targetText; + + public override void AfterAwake() + { + Button_PrevMonth.onClick.AddListener(OnClickPrevMonth); + Button_NextMonth.onClick.AddListener(OnClickNextMonth); + + prefab_calendarItem = Resources.Load("Prefabs/UI/PRF_UI_CalendarItem"); + float sundayPosX = Text_Sunday.anchoredPosition.x; + float mondayPosX = Text_Monday.anchoredPosition.x; + float space = mondayPosX - sundayPosX; + Vector2 prefabSize = prefab_calendarItem.GetComponent().sizeDelta; + Vector2 itemStartPos = new Vector2(Text_Sunday.anchoredPosition.x, Text_Sunday.anchoredPosition.y - space); + + for (int i = 0; i < totalItemNum; i++) + { + UI_CalendarItem item = Instantiate(prefab_calendarItem.gameObject, ItemRoot).GetComponent(); + item.onClickEvent += OnClickItem; + item.GetComponent().anchoredPosition = new Vector3((i % 7) * space + itemStartPos.x, itemStartPos.y - (i / 7) * space); + calendarItemList.Add(item); + } + } + + public void Open(TextMeshProUGUI target) + { + targetText = target; + originDateTime = Convert.ToDateTime(targetText.text); + curDateTime = Convert.ToDateTime(targetText.text); + SetActive(true); + SetCalendar(); + } + + public void Close() + { + SetActive(false); + } + + void SetCalendar() + { + DateTime firstDay = curDateTime.AddDays(-(curDateTime.Day - 1)); + int weekIndex = (int)firstDay.DayOfWeek; + int curMonthDaysCount = DateTime.DaysInMonth(curDateTime.Year, curDateTime.Month); + DateTime lastMonth = firstDay.AddDays(-1); + int lastMonthDaysCount = DateTime.DaysInMonth(lastMonth.Year, lastMonth.Month); + DateTime today = DateTime.Today; + + int date = 0; + + for (int i = 0; i < totalItemNum; i++) + { + if (i >= weekIndex) + { + DateTime day = firstDay.AddDays(date); + if (day.Month == firstDay.Month) // ÇöÀç ´Þ + { + calendarItemList[i].SetDate(day, Color.black); + + if (originDateTime.Date == day.Date) + { + calendarItemList[i].ShowSelectUI(); + } + else if(today == day.Date) + { + calendarItemList[i].ShowTodayUI(); + } + } + else // ´ÙÀ½ ´Þ + { + int nextMonthDay = date + 1 - curMonthDaysCount; + DateTime nextMonthDate = new DateTime(day.Year, day.Month, nextMonthDay); + calendarItemList[i].SetDate(nextMonthDate, Color.gray); + + if (today == nextMonthDate) + { + calendarItemList[i].ShowTodayUI(); + } + } + + date++; + } + else // ÀÌÀü ´Þ + { + DateTime dayInLastMonth = new DateTime(lastMonth.Year, lastMonth.Month, lastMonthDaysCount - (weekIndex - i - 1)); + calendarItemList[i].SetDate(dayInLastMonth, Color.gray); + + if (today == dayInLastMonth) + { + calendarItemList[i].ShowTodayUI(); + } + } + } + + Text_Day.text = $"{curDateTime.ToString("MMMM", new CultureInfo("en-US"))} {curDateTime.Year}"; + } + + private void OnClickItem(DateTime date) + { + targetText.text = date.ToString("yyyy-MM-dd"); + Close(); + } + + private void OnClickPrevMonth() + { + curDateTime = curDateTime.AddMonths(-1); + SetCalendar(); + } + + private void OnClickNextMonth() + { + curDateTime = curDateTime.AddMonths(1); + SetCalendar(); + } +} diff --git a/Assets/Scripts/PGD/UI_Calendar.cs.meta b/Assets/Scripts/PGD/UI_Calendar.cs.meta new file mode 100644 index 00000000..d4caecc7 --- /dev/null +++ b/Assets/Scripts/PGD/UI_Calendar.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1ab8c7ef5fa70aa4fb6b5cb0f1aea1a0 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/PGD/UI_CalendarItem.cs b/Assets/Scripts/PGD/UI_CalendarItem.cs new file mode 100644 index 00000000..6a0bc6b5 --- /dev/null +++ b/Assets/Scripts/PGD/UI_CalendarItem.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using TMPro; +using UnityEngine; +using UnityEngine.EventSystems; +using UnityEngine.UI; +using WI; + +public class UI_CalendarItem : UIBase, IPointerEnterHandler, IPointerExitHandler, IPointerClickHandler +{ + DateTime targetDate; + + public Action onClickEvent; + public Image HoverUI; + public Image SelectUI; + public Image TodayUI; + public TextMeshProUGUI Text_Day; + + public void OnDisable() + { + Init(); + } + + private void Init() + { + HoverUI.gameObject.SetActive(false); + SelectUI.gameObject.SetActive(false); + TodayUI.gameObject.SetActive(false); + Text_Day.text = string.Empty; + } + + public void SetDate(DateTime date, Color color) + { + Init(); + targetDate = date; + Text_Day.text = date.Day.ToString(); + Text_Day.color = color; + } + + public void Close() + { + SetActive(false); + } + + public void ShowSelectUI() + { + SelectUI.gameObject.SetActive(true); + } + + public void ShowTodayUI() + { + TodayUI.gameObject.SetActive(true); + } + + public void OnPointerClick(PointerEventData eventData) + { + onClickEvent?.Invoke(targetDate); + } + + public void OnPointerEnter(PointerEventData eventData) + { + if (TodayUI.IsActive()) + return; + + HoverUI.gameObject.SetActive(true); + } + + public void OnPointerExit(PointerEventData eventData) + { + HoverUI.gameObject.SetActive(false); + } +} diff --git a/Assets/Scripts/PGD/UI_CalendarItem.cs.meta b/Assets/Scripts/PGD/UI_CalendarItem.cs.meta new file mode 100644 index 00000000..29dc72dc --- /dev/null +++ b/Assets/Scripts/PGD/UI_CalendarItem.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 82f43be8f5583ee4c8d6f3ef1b8bb308 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/UI/Panel_WorkConditionAnalysis.cs b/Assets/Scripts/UI/Panel_WorkConditionAnalysis.cs index b6ed7e63..016e17c4 100644 --- a/Assets/Scripts/UI/Panel_WorkConditionAnalysis.cs +++ b/Assets/Scripts/UI/Panel_WorkConditionAnalysis.cs @@ -3,18 +3,49 @@ using System.Collections.Generic; using UnityEngine; using WI; using UnityEngine.UI; +using TMPro; +using System; namespace CHN { public class Panel_WorkConditionAnalysis : PanelBase { - Button Button_Close; + private Button Button_StartDay; + private Button Button_EndDay; + private TextMeshProUGUI Text_StartDay; + private TextMeshProUGUI Text_EndDay; + private TMP_Dropdown Dropdown_Facility; + private TMP_InputField InputField_WorkOrderNumber; + private Button Button_Search; + private Button Button_Close; + + private UI_Calendar ui_Calendar; public override void AfterAwake() { + ui_Calendar = transform.GetComponentInChildren(); Button_Close.onClick.AddListener(() => SetActive(false)); + Button_StartDay.onClick.AddListener(OnClickStartDayBtn); + Button_EndDay.onClick.AddListener(OnClickEndDayBtn); + + ui_Calendar.Close(); + + Text_StartDay.text = DateTime.Now.ToString("yyyy-MM-dd"); + Text_EndDay.text = DateTime.Now.ToString("yyyy-MM-dd"); + SetActive(false); } + + private void OnClickStartDayBtn() + { + ui_Calendar.Open(Text_StartDay); + } + + private void OnClickEndDayBtn() + { + ui_Calendar.Open(Text_EndDay); + } + public void Open() { SetActive(true);