Esempio n. 1
0
    void AddMap()
    {
        if (LstMaps.CurrentSelection < 0)
        {
            return;
        }

        string mapluafile = MapLuaFiles[LstMaps.CurrentSelection];

        int[] modeIndices = LstModes.GetCheckedIndices();
        int[] eraIndices  = LstEras.GetCheckedIndices();

        for (int i = 0; i < modeIndices.Length; ++i)
        {
            SubIcon modeSub = ModeSubs[modeIndices[i]];

            for (int j = 0; j < eraIndices.Length; j++)
            {
                SubIcon eraSub = EraSubs[eraIndices[j]];

                string         mapName = ENV.GetLocalizedMapName(mapluafile);
                PhxListBoxItem item    = LstRotation.AddItem(mapName);
                item.SetIcon(modeSub.Icon);
                item.SetIcon2(eraSub.Icon);

                string mapScript = SWBFHelpers.Format(mapluafile, eraSub.Sub, modeSub.Sub);
                RotationLuaFiles.Add(mapScript);
            }
        }
    }
        public override void ProcessInput(Event ev)
        {
            SubIcon icon = lastClicked;

            if (icon.state)
            {
                icon.unapply(parent);
            }
            else
            {
                icon.apply(parent);
            }
        }
        //this and class mess below was supposed to be quick shortcut to not write four repeated chunks of code in GizmoOnGUI
        private bool DrawSubIcon(SubIcon icon)
        {
            if (!icon.applicable(parent))
            {
                return(false);
            }
            //Log.Message("sub gizmo");
            Rect iconRect = new Rect(gizmoRect.x + icon.offset.x, gizmoRect.y + icon.offset.y, IconSize, IconSize);

            TooltipHandler.TipRegion(iconRect, icon.desc(parent).Translate());
            bool      applied = icon.applied(parent);
            Texture2D texture = applied ? icon.cancel : icon.texture(parent);

            GUI.DrawTexture(iconRect, texture);
            //GUI.color = Color.white;

            return(Widgets.ButtonInvisible(iconRect, false));
        }
        public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth)
        {
            Rect rect = new Rect(topLeft.x, topLeft.y, 75f, 75f);

            gizmoRect = rect.ContractedBy(ContentPadding);
            Widgets.DrawWindowBackground(rect);

            //Log.Message("RJWgizmo");
            foreach (SubIcon icon in subIcons)
            {
                if (DrawSubIcon(icon))
                {
                    lastClicked = icon;
                    icon.state  = icon.applied(parent);
                    return(new GizmoResult(GizmoState.Interacted, Event.current));
                }
            }
            return(new GizmoResult(GizmoState.Clear));
        }