public void Init(UIModule widget, GameObject hardpointtext, GameObject jjtext, Vector2 position)
        {
            var hp_layout = hardpointtext.transform.parent.parent;

            var horizontal = hp_layout.GetComponent <HorizontalLayoutGroup>();

            GameObject.DestroyImmediate(horizontal);
            var jj_layout = jjtext.transform.parent.parent;



            var grid = hp_layout.gameObject.AddComponent <GridLayoutGroup>();

            //grid.childControlHeight = true;
            //vertical.childControlWidth = true;
            grid.padding         = new RectOffset(3, 3, 3, 3);
            grid.spacing         = new Vector2(1, 1);
            grid.childAlignment  = TextAnchor.MiddleCenter;
            grid.constraint      = GridLayoutGroup.Constraint.FixedColumnCount;
            grid.constraintCount = 5;
            grid.cellSize        = new Vector2(60, 32);
            var transform = hp_layout.GetComponent <RectTransform>();

            transform.anchoredPosition = position;
            transform.sizeDelta        = new Vector2(295, 66);
            grid.enabled = true;

            var fitter = hp_layout.gameObject.AddComponent <ContentSizeFitter>();

            fitter.verticalFit   = ContentSizeFitter.FitMode.MinSize;
            fitter.horizontalFit = ContentSizeFitter.FitMode.MinSize;


            var jj     = jj_layout.GetChild(0);
            var sample = make_samlpe(hp_layout);

            foreach (Transform child in hp_layout)
            {
                if (child != sample)
                {
                    GameObject.Destroy(child.gameObject);
                }
            }

            var jjgo = GameObject.Instantiate(sample.gameObject);

            jjhardpoint = new JJHardpointHeler(jjgo, jj);
            hardpoints  = new Dictionary <int, HardpointHelper>();

            jjgo.transform.SetParent(hp_layout);
            foreach (var hpinfo in HardpointController.Instance.HardpointsList.Where(i => i.Visible))
            {
                var hpgo = GameObject.Instantiate(sample.gameObject);
                hardpoints[hpinfo.WeaponCategory.ID] = new MechlabHardpointHelper(hpgo, hpinfo);
                hpgo.transform.SetParent(hp_layout);
            }

            GameObject.Destroy(sample.gameObject);
            GameObject.Destroy(jj_layout.gameObject);
        }
Example #2
0
 private void Start()
 {
     Framework.InitEnv("Game_RT", EnvironmentType.Ev1).InitWithAttribute();
     module = Framework.env1.modules.CreateModule <UIModule>();
     module.AddLoader(this);
     module.SetGroups(new MvvmGroups(UIMap_MVVM.map));
 }
Example #3
0
    void Start()
    {
        inputHandler = gameObject.GetComponent <InputHandler>();
        TimeSystem.GetTimeSystem().AddTimer(this);
        uiModule = GiraffeSystem.FindModule <UIModule>();

        playerCamera = gameObject.GetComponentInChildren <RaceCamera>();
        rigidbody    = gameObject.GetComponentInChildren <Rigidbody>();

        var root = GameObject.Find("Root");

        indicator = root.FindChildByName("Billboard").GetComponent <EmoticonIndicator>();
        ghost     = root.FindChildByName("Ghost");

        //inputHandler.OnUpKey = () => { AddForce(Vector3.back); };
        inputHandler.OnDownKey     = () => { AddForce(Vector3.forward); };
        inputHandler.OnLeftKey     = () => { AddForce(Vector3.left); };
        inputHandler.OnRightKey    = () => { AddForce(Vector3.right); };
        inputHandler.OnInputFinish = ProcessForce;
        inputHandler.OnSpaceDown   = TryBooster;

        // audio
        dragging = gameObject.FindChildByName("Dragging").GetComponent <AudioSource>();
        booster  = gameObject.FindChildByName("Booster").GetComponent <AudioSource>();
    }
Example #4
0
        /// <summary>
        /// Create a new instance of the game engine. A user
        /// is required to know how to run the engine.
        /// </summary>
        /// <param name="context">The executing context of the engine.</param>
        /// <param name="serviceLocator">The dependency locator.</param>
        protected GameEngine(IContext context, ServiceLocator serviceLocator)
        {
            if (instance != null)
            {
                throw new Exception("Two or more instances of the game engine exist!");
            }

            this.Context        = context;
            this.serviceLocator = serviceLocator;

            LogModule     = new LogModule(this);
            ConfigModule  = new ConfigModule(this);
            UserModule    = new UserModule(this);
            CommandModule = new CommandConsoleModule(this);
            UIModule      = new UIModule(this);
            NetModule     = new NetModule(this);
            InputModule   = new InputModule(this);

            this.Context.EngineTicker.OnInit   += OnTickerInit;
            this.Context.EngineTicker.OnStart  += OnTickerStart;
            this.Context.EngineTicker.OnUpdate += OnTickerUpdate;
            this.Context.EngineTicker.OnEnd    += OnTickerEnd;

            SceneManager.sceneLoaded += SceneManagerSceneLoaded;
            instance = this;
            Core.Context.SetContext(context);
        }
Example #5
0
        internal Editor()
        {
            Instance = this;

            Log("Setting up C# Editor...");

            Internal_GetProjectInfo(out _projectInfo);

            // Create common editor modules
            RegisterModule(Windows           = new WindowsModule(this));
            RegisterModule(UI                = new UIModule(this));
            RegisterModule(Thumbnails        = new ThumbnailsModule(this));
            RegisterModule(Simulation        = new SimulationModule(this));
            RegisterModule(Scene             = new SceneModule(this));
            RegisterModule(SceneEditing      = new SceneEditingModule(this));
            RegisterModule(ContentEditing    = new ContentEditingModule(this));
            RegisterModule(ContentDatabase   = new ContentDatabaseModule(this));
            RegisterModule(ContentImporting  = new ContentImportingModule(this));
            RegisterModule(CodeEditing       = new CodeEditingModule(this));
            RegisterModule(ProgressReporting = new ProgressReportingModule(this));

            StateMachine = new EditorStateMachine(this);
            Undo         = new EditorUndo(this);

            ScriptsBuilder.ScriptsReloadBegin += ScriptsBuilder_ScriptsReloadBegin;
            ScriptsBuilder.ScriptsReloadEnd   += ScriptsBuilder_ScriptsReloadEnd;
        }
Example #6
0
        internal Editor()
        {
            Instance = this;

            Log("Setting up C# Editor...");

            Internal_GetProjectInfo(out _projectInfo);

            Icons = new EditorIcons();
            Icons.GetIcons();

            // Create common editor modules
            RegisterModule(Options           = new OptionsModule(this));
            RegisterModule(ProjectCache      = new ProjectCacheModule(this));
            RegisterModule(Scene             = new SceneModule(this));
            RegisterModule(Windows           = new WindowsModule(this));
            RegisterModule(UI                = new UIModule(this));
            RegisterModule(Thumbnails        = new ThumbnailsModule(this));
            RegisterModule(Simulation        = new SimulationModule(this));
            RegisterModule(Prefabs           = new PrefabsModule(this));
            RegisterModule(SceneEditing      = new SceneEditingModule(this));
            RegisterModule(ContentEditing    = new ContentEditingModule(this));
            RegisterModule(ContentDatabase   = new ContentDatabaseModule(this));
            RegisterModule(ContentImporting  = new ContentImportingModule(this));
            RegisterModule(CodeEditing       = new CodeEditingModule(this));
            RegisterModule(ProgressReporting = new ProgressReportingModule(this));
            RegisterModule(ContentFinding    = new ContentFindingModule(this));

            StateMachine = new EditorStateMachine(this);
            Undo         = new EditorUndo(this);

            ScriptsBuilder.ScriptsReloadBegin   += ScriptsBuilder_ScriptsReloadBegin;
            ScriptsBuilder.ScriptsReloadEnd     += ScriptsBuilder_ScriptsReloadEnd;
            UIControl.FallbackParentGetDelegate += OnUIControlFallbackParentGet;
        }
Example #7
0
        public ActionResult AddUIModule(AddEditUIModuleViewModel vModel)
        {
            ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId());

            UIModule newObj = new UIModule
            {
                Name     = vModel.Name,
                BodyHtml = vModel.BodyHtml,
                Height   = vModel.Height,
                Width    = vModel.Width,
                HelpText = vModel.HelpText
            };
            string message;

            if (newObj.Create(authedUser.GameAccount, authedUser.GetStaffRank(User)) == null)
            {
                message = "Error; Creation failed.";
            }
            else
            {
                LoggingUtility.LogAdminCommandUsage("*WEB* - AddUIModule[" + newObj.Id.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle);
                message = "Creation Successful.";
            }

            return(RedirectToAction("UIModules", new { Message = message }));
        }
Example #8
0
    private void OnLoadCompleted(AssetRequest request)
    {
        m_assetRequest = request;
        if (!string.IsNullOrEmpty(request.error))
        {
            request.Release();
            GameLog.LogError("加载界面失败:" + panelName);
            return;
        }

        m_loadState = LoadState.LOADED;

        // 实例化
        m_parent   = UIModule.GetParent(viewType);
        gameObject = GameObject.Instantiate(request.asset as GameObject, m_parent);
        gameObject.SetActive(true);
        gameObject.name = request.asset.name;

        transform = gameObject.transform;
        UI        = HierarchyUtil.GetHierarchyItems(gameObject);

        OnLoaded();
        AddAllListener();

        if (m_loadedCallback != null)
        {
            m_loadedCallback(this);
        }
    }
    private void ShowMask()
    {
        if (m_LucencyType == LucencyType.Translucence)
        {
            if (m_blurTextureOnce == null)
            {
                m_UIMask = UIModule.GetUIMask();

                m_blurTextureOnce = m_UIMask.GetComponent <BlurTextureOnce>();
                m_blurTextureOnce.Init();
            }
            m_UIMask.transform.localPosition = Vector3.zero;

            // 移走自己,以防被相机拍到
            MoveFarAway(true);
            m_blurTextureOnce.GenerateRender();
            MoveFarAway(false);
        }

        if (m_UIMask != null)
        {
            m_UIMask.GetComponent <RawImage>().raycastTarget = m_raycast;
        }

        if (m_raycast)
        {
            ClickListener.AddClick(m_blurTextureOnce, OnClickMask);
        }
    }
        public static void Initialize()
        {
            ContainerModule.Initialize();
            CoreModule.Initialize();
            MathModule.Initialize();
            EngineModule.Initialize();
            InputModule.Initialize();
            IOModule.Initialize();
            ResourceModule.Initialize();
            AudioModule.Initialize();
            GraphicsModule.Initialize();
            SceneModule.Initialize();
            Atomic2DModule.Initialize();
            Atomic3DModule.Initialize();
            NavigationModule.Initialize();
            NetworkModule.Initialize();
            PhysicsModule.Initialize();
            EnvironmentModule.Initialize();
            UIModule.Initialize();

            AtomicPlayer.PlayerModule.Initialize();

            AtomicInterop.Initialize();

            atomicsharp_initialize();

            initSubsystems();
        }
Example #11
0
 private static void OnSceneLoaded(AssetRequest assetRequest)
 {
     //调用ui模块的进入场景
     UIModule.SceneEnter();
     // 当前场景OnEnter
     m_curScene.OnEnter();
     //发送场景切换事件
 }
Example #12
0
        void Init()
        {
            uiModule = new UIModule();


            UIModule.Init();
            //LString.Load_UIString();//加载本地化文件.
        }
Example #13
0
 public GameObject GetUIObject(UIModule Mode)
 {
     if (_uiOpenMap.ContainsKey((int)Mode))
     {
         return(_uiOpenMap[(int)Mode]);
     }
     return(null);
 }
Example #14
0
        public static void Display(ArraysAddressList arrayAddressList, UIModule parentModule)
        {
            if (arrayAddressList == null)
            {
                throw new InvalidOperationException("No array selected !");
            }

            UIModuleFactory.CreateModule <ArrayInstancesModule>(module => { module.UIModuleParent = parentModule; module.Setup(arrayAddressList); }, module => parentModule.RequestDockModule(module));
        }
Example #15
0
        public static void Initialize()
        {
            // Atomic Modules
            CoreModule.Initialize();
            MathModule.Initialize();
            EngineModule.Initialize();
            InputModule.Initialize();
            IOModule.Initialize();
            ResourceModule.Initialize();
            AudioModule.Initialize();
            GraphicsModule.Initialize();
            SceneModule.Initialize();
            Atomic2DModule.Initialize();
            NavigationModule.Initialize();
            NetworkModule.Initialize();
            PhysicsModule.Initialize();
            EnvironmentModule.Initialize();
            UIModule.Initialize();

#if ATOMIC_DESKTOP
            IPCModule.Initialize();
#endif

            AtomicAppModule.Initialize();
            ScriptModule.Initialize();

            AtomicNETScriptModule.Initialize();
            AtomicNETNativeModule.Initialize();

            PlayerModule.Initialize();

            coreDelegates = new CoreDelegates();
            coreDelegates.eventDispatch  = NativeCore.EventDispatch;
            coreDelegates.updateDispatch = NativeCore.UpdateDispatch;

            IntPtr coreptr = csi_Atomic_NETCore_Initialize(ref coreDelegates);

            NETCore core = (coreptr == IntPtr.Zero ? null : NativeCore.WrapNative <NETCore>(coreptr));

            if (core != null)
            {
                AtomicNET.RegisterSubsystem("NETCore", core);
            }

            context = core.Context;

            NativeCore.Initialize();
            CSComponentCore.Initialize();

#if ATOMIC_DESKTOP
            string[] arguments = Environment.GetCommandLineArgs();
            foreach (string arg in arguments)
            {
                AppBase.AddArgument(arg);
            }
#endif
        }
Example #16
0
        protected sealed override void Init()
        {
            logSource = base.logger;
            Log.Message("Sniper initializing");
            instance = this;


            base.awake += () =>
            {
                SetModdedModule.SetModded();
                ReinCore.AddModHash(guid, Properties.Info.ver, useBuild, useRev, networkVer);
                ConfigModule.CreateAndLoadConfig(this);

                Properties.Tools.RegisterLanguageTokens();
                SoundModule.LoadBank();
                NetworkModule.SetupNetworking();

                Default <Sprite> .value = UIModule.GetUnfinishedIcon();
                UIModule.EditHudPrefab();

                PrefabModule.CreatePrefab();
                DisplayModule.CreateDisplayPrefab();

                CatalogModule.RegisterBody();
                CatalogModule.RegisterSurvivor();
                CatalogModule.RegisterDoTType();
                CatalogModule.RegisterDamageTypes();
                CatalogModule.RegisterBuffTypes();
                CatalogModule.RegisterOrbs();
                CatalogModule.RegisterOverlays();

                VFXModule.Init();

                //UnlocksCore.AddUnlockable<WIPUnlockable>(false);
            };

            base.start += () =>
            {
                //MetaCatalog.LogCatalogState();

                try
                {
                    RoR2.Console.instance.SubmitCmd(null, "spp_disable_survivor Sniper");
                } catch { }
                _ = TextureModule.GetExplosiveAmmoRamp();
                _ = TextureModule.GetPlasmaAmmoRamp();
                _ = TextureModule.GetStandardAmmoRamp();
                _ = TextureModule.GetShockAmmoRamp();
                _ = TextureModule.GetScatterAmmoRamp();
            };

            base.enable      += HooksModule.Add;
            base.disable     += HooksModule.Remove;
            base.fixedUpdate += () => dt = Time.fixedDeltaTime;
            Log.Message("Sniper loaded successfully");
        }
Example #17
0
 public void CloseUI(UIModule Mode)
 {
     if (_uiOpenMap.ContainsKey((int)Mode))
     {
         if (_uiOpenMap[(int)Mode])
         {
             Destroy(_uiOpenMap[(int)Mode]);
             _uiOpenMap[(int)Mode] = null;
         }
     }
 }
 public static void Create(ClrDumpType clrDumpType, UIModule parent, Action <InstancesModule> postInit)
 {
     if (clrDumpType == null)
     {
         MessageBox.Show("No type selected !", "Error", MessageBoxButtons.OK);
         return;
     }
     UIModuleFactory.CreateModule <TypeInstancesModule>(
         mod => { mod.UIModuleParent = parent; mod.Setup(clrDumpType); },
         mod => postInit(mod)
         );
 }
Example #19
0
    public void FillBuilderUI(UIModule uim)
    {
        if (uim != uiModule)
        {
            Debug.Log("Symbol: " + uim.Module.Symbol);
            Debug.Log("Growth: " + uim.Module.Growth);
            uim.GetComponent <Image>().color = Color.green;
            if (uiModule != null)
            {
                uiModule.GetComponent <Image>().color = Color.white;
            }
            uiModule   = uim;
            editModule = true;  //Distinguish between true edit and UI change
            DisablePanels();
            if (productions.currentProduction.RHS.IndexOf(uim) != productions.currentProduction.RHS.Count - 1)
            {
                symbolDropdown.gameObject.SetActive(true);
                switch (currentModule.Symbol)
                {
                case Parametric_Turtle.DRAW:
                    DrawPanel.gameObject.SetActive(true);
                    lineBuilder.SetUI(currentModule as LineModule);
                    break;

                case Parametric_Turtle.JOINT_OPEN:
                    JointPanel.gameObject.SetActive(true);
                    jointBuilder.SetUI(currentModule as JointModule);
                    break;

                case Parametric_Turtle.OBJECT:
                    ObjectPanel.gameObject.SetActive(true);
                    objectBuilder.SetUI(currentModule as ObjectModule);
                    break;

                case Parametric_Turtle.ROTATE:
                    RotationPanel.gameObject.SetActive(true);
                    rotationBuilder.SetUI(currentModule as RotationModule);
                    break;

                default:
                    break;
                }
                symbolDropdown.value     = symbolDictionary[currentModule.Symbol.ToString()]; //Will trigger SetSymbol
                terminalAge.Slider.value = currentModule.TerminalAge;
                growthBuilder.SetUI(currentModule);
            }
            else
            {
                symbolDropdown.gameObject.SetActive(false);
            }
            editModule = false;
        }
    }
Example #20
0
    private static void ExitLastScene()
    {
        //卸载上一个场景,
        if (m_curScene != null)
        {
            m_curScene.OnExit();
        }

        //调用ui模块的退出场景,
        UIModule.SceneExit();
        // 卸载AB
        //主动触发GC
        System.GC.Collect();
        //清理内存
        Resources.UnloadUnusedAssets();
    }
    public void AppendModule(SystemModule m)
    {
        SystemModule newMod = m.CopyModule();
        GameObject   newRHS = GameObject.Instantiate(Resources.Load("Prefabs/UI/Module")) as GameObject;

        newRHS.transform.SetParent(panelRHS.transform, false);
        newRHS.transform.SetSiblingIndex(SelectedModule.gameObject.transform.GetSiblingIndex());
        newRHS.GetComponentInChildren <Text>().text = m.Symbol.ToString();

        UIModule uim = newRHS.GetComponent <UIModule>();

        SelectedModule = uim;
        RHS.Insert(SelectedModule.transform.GetSiblingIndex(), uim);
        uim.Production = this;
        uim.Module     = newMod;
        uim.InstantiateUI();
    }
Example #22
0
        public static void Initialize()
        {
            // Atomic Modules
            CoreModule.Initialize();
            MathModule.Initialize();
            EngineModule.Initialize();
            InputModule.Initialize();
            IOModule.Initialize();
            ResourceModule.Initialize();
            AudioModule.Initialize();
            GraphicsModule.Initialize();
            SceneModule.Initialize();
            Atomic2DModule.Initialize();
            Atomic3DModule.Initialize();
            NavigationModule.Initialize();
            NetworkModule.Initialize();
            PhysicsModule.Initialize();
            EnvironmentModule.Initialize();
            UIModule.Initialize();
            IPCModule.Initialize();
            AtomicAppModule.Initialize();
            ScriptModule.Initialize();

            AtomicNETScriptModule.Initialize();
            AtomicNETNativeModule.Initialize();

            PlayerModule.Initialize();

            coreDelegates = new CoreDelegates();
            coreDelegates.eventDispatch  = NativeCore.EventDispatch;
            coreDelegates.updateDispatch = NativeCore.UpdateDispatch;

            IntPtr coreptr = csb_Atomic_NETCore_Initialize(ref coreDelegates);

            NETCore core = (coreptr == IntPtr.Zero ? null : NativeCore.WrapNative <NETCore>(coreptr));

            if (core != null)
            {
                AtomicNET.RegisterSubsystem("NETCore", core);
            }

            context = core.Context;

            NativeCore.Initialize();
            CSComponentCore.Initialize();
        }
Example #23
0
 public static void Display(UIModule parentModule, ClrDumpObject data)
 {
     if (data.ClrType.IsArray)
     {
         var    elementsAddresses = new ArrayElementsAddressContainer(data);
         var    addresses         = new AddressList(data.ClrDump, data.ClrType.ComponentType, elementsAddresses);
         string name = $"{data.ClrDump.Id} - Elements: {data.Address:X} [{data.ClrType.ComponentType.Name}]";
         InstancesModule.Create(addresses, parentModule, mod => DockModule(parentModule.MessageBus, mod), name);
     }
     else
     {
         UIModuleFactory.CreateModule <InstanceDetailsModule>(
             mod => { mod.UIModuleParent = parentModule; mod.Setup(data); },
             mod => DockModule(parentModule.MessageBus, mod, DockState.DockRight)
             );
     }
 }
Example #24
0
 public static void Create(ClrDump clrDump, IAddressContainer addresses, UIModule parent, Action <InstancesMixedModule> postInit, string name = null)
 {
     if (addresses == null)
     {
         MessageBox.Show("No instances selected !", "Error", MessageBoxButtons.OK);
         return;
     }
     UIModuleFactory.CreateModule <InstancesMixedModule>(
         mod => {
         mod.UIModuleParent = parent; mod.Setup(clrDump, addresses);
         if (name != null)
         {
             mod.Name = name;
         }
     },
         mod => postInit(mod)
         );
 }
Example #25
0
 public void OpenUI(UIModule Mode)
 {
     if (_uiOpenMap.ContainsKey((int)Mode))
     {
         if (!_uiOpenMap[(int)Mode])
         {
             GameObject UIObj = GameObject.Instantiate(UIPrefabList[(int)Mode], Vector3.zero, Quaternion.identity) as GameObject;
             UIObj.transform.parent = this.transform;
             RectTransform Rect = UIObj.GetComponent <RectTransform>();
             Rect.localPosition    = Vector3.zero;
             _uiOpenMap[(int)Mode] = UIObj;
         }
     }
     else
     {
         GameObject UIObj = GameObject.Instantiate(UIPrefabList[(int)Mode], Vector3.zero, Quaternion.identity) as GameObject;
         UIObj.transform.parent = this.transform;
         RectTransform Rect = UIObj.GetComponent <RectTransform>();
         Rect.localPosition = Vector3.zero;
         _uiOpenMap.Add((int)Mode, UIObj);
     }
 }
Example #26
0
 static public void Initialize()
 {
     ContainerModule.Initialize();
     CoreModule.Initialize();
     MathModule.Initialize();
     EngineModule.Initialize();
     InputModule.Initialize();
     IOModule.Initialize();
     ResourceModule.Initialize();
     AudioModule.Initialize();
     GraphicsModule.Initialize();
     SceneModule.Initialize();
     Atomic2DModule.Initialize();
     Atomic3DModule.Initialize();
     NavigationModule.Initialize();
     NetworkModule.Initialize();
     PhysicsModule.Initialize();
     EnvironmentModule.Initialize();
     UIModule.Initialize();
     NETCoreModule.Initialize();
     NETScriptModule.Initialize();
     AtomicPlayer.PlayerModule.Initialize();
 }
Example #27
0
        public ActionResult Add(AddEditUIModuleViewModel vModel)
        {
            string          message    = string.Empty;
            ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId());

            UIModule newObj = new UIModule
            {
                Name          = vModel.Name,
                BodyHtml      = vModel.BodyHtml,
                Height        = vModel.Height,
                Width         = vModel.Width,
                HelpText      = vModel.HelpText,
                SystemDefault = vModel.SystemDefault
            };

            IEnumerable <IUIModule> uiModules = TemplateCache.GetAll <IUIModule>().Where(uim => vModel.SystemDefault > 0 && uim.SystemDefault == vModel.SystemDefault);

            if (newObj.Create(authedUser.GameAccount, authedUser.GetStaffRank(User)) == null)
            {
                message = "Error; Creation failed.";
            }
            else
            {
                if (uiModules.Count() > 0)
                {
                    IUIModule revertModule = uiModules.First();
                    revertModule.SystemDefault = 0;
                    revertModule.Save(authedUser.GameAccount, StaffRank.Admin);
                }

                LoggingUtility.LogAdminCommandUsage("*WEB* - AddUIModule[" + newObj.Id.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle);
                message = "Creation Successful.";
            }

            return(RedirectToAction("Index", new { Message = message }));
        }
Example #28
0
 /// <summary>
 /// When the engine starts up load the login menu
 /// so the user can sign in.
 /// </summary>
 protected override void OnStart()
 {
     UIModule.LoadMenu <LoginMenu>();
 }
Example #29
0
        /// <summary>
        /// Create editable controls
        /// </summary>
        /// <param name="controlAnalyze">Analyze of property</param>
        /// <param name="previousControl">Previous control</param>
        /// <param name="uiModule">UI module</param>
        /// <returns>New control</returns>
        public static UIElement CreateEditableControl(KeyValuePair <string, PropertyAnalyze> controlAnalyze, ref UIElement previousControl, UIModule uiModule)
        {
            string            controlName     = controlAnalyze.Key;
            PropertyAnalyze   controlData     = controlAnalyze.Value;
            PropertyType      controlTypeName = controlData.PropertyType;
            UIElement         control;
            UIParamsAttribute customization = controlData.PropertyAttributes.FirstOrDefault(x => x.GetType() == typeof(UIParamsAttribute)) as UIParamsAttribute;

            var linkedTableAttribute = controlData.PropertyAttributes.FirstOrDefault(x => x.GetType() == typeof(LinkedTableAttribute)) as LinkedTableAttribute;

            if (linkedTableAttribute != null)
            {
                switch (linkedTableAttribute.LinkedTableRelation)
                {
                case LinkedTableRelation.One:
                    control = LinkedTableSingleSelectorControl.CreateLinkedTableControl(controlName, controlData, controlTypeName, linkedTableAttribute);
                    break;

                case LinkedTableRelation.Many:
                    control = LinkedTableMultiSelectorControl.CreateLinkedTableControl(controlName, controlData, controlTypeName, linkedTableAttribute);
                    break;

                default:
                    throw new NotSupportedPropertyTypeException("Not supported LinkedTableRelation.");
                }
            }
            else
            {
                switch (controlTypeName)
                {
                case PropertyType.String:
                case PropertyType.Int:
                case PropertyType.Int32:
                case PropertyType.Double:
                case PropertyType.Char:
                case PropertyType.Decimal:
                case PropertyType.Float:

                    control = new TextBox()
                    {
                        Name            = controlName + Constants.DATA_CONTROL_IDENTIFIER,
                        Margin          = new Thickness(10),
                        TextWrapping    = TextWrapping.Wrap,
                        PlaceholderText = "Insert " + controlName
                    };

                    if (controlTypeName == PropertyType.Char)
                    {
                        (control as TextBox).MaxLength = 1;
                    }

                    if (customization != null && customization.UseLongTextInput)
                    {
                        (control as TextBox).Height = 150;
                    }
                    break;

                case PropertyType.Boolean:
                    control = new CheckBox()
                    {
                        Content = controlName,
                        Margin  = new Thickness(10),
                        Name    = controlName + Constants.DATA_CONTROL_IDENTIFIER
                    };
                    break;

                case PropertyType.DateTime:

                    if (customization == null)
                    {
                        throw new MissingRequiredAdditionalDataException("Property DateTime require UIParams attribute for specificating design.");
                    }

                    control = new Grid()
                    {
                        Margin = new Thickness(10)
                    };

                    RowDefinition labelRow = new RowDefinition()
                    {
                        Height = new GridLength(1, GridUnitType.Auto)
                    };

                    RowDefinition dateTimeRow = new RowDefinition()
                    {
                        Height = new GridLength(1, GridUnitType.Auto)
                    };

                    (control as Grid).RowDefinitions.Add(labelRow);
                    (control as Grid).RowDefinitions.Add(dateTimeRow);

                    TextBlock label = new TextBlock()
                    {
                        Name = controlName + Constants.LABEL_CONTROL_IDENTIFIER,
                        Text = customization == null?controlTypeName.ToString() : customization.LabelDescription,
                                   VerticalAlignment = VerticalAlignment.Center,
                                   Margin            = new Thickness(0, 0, 0, 5)
                    };
                    Grid.SetRow(label, 0);
                    (control as Grid).Children.Add(label);

                    //if (customization.ReadOnlyMode)
                    //{
                    //    TextBox data = new TextBox()
                    //    {
                    //        Text = "",
                    //        VerticalAlignment = VerticalAlignment.Center,
                    //        Margin = new Thickness(0, 0, 0, 5),
                    //        Name = controlName + DATA_CONTROL_IDENTIFIER
                    //    };
                    //}
                    //else
                    //{
                    //    TextBlock data = new TextBlock()
                    //    {
                    //        Text = "",
                    //        VerticalAlignment = VerticalAlignment.Center,
                    //        Margin = new Thickness(0, 0, 0, 5),
                    //        Name = controlName + DATA_CONTROL_IDENTIFIER
                    //    };
                    //}

                    UIElement dateTimeControl;

                    switch (customization.DateTimeMode)
                    {
                    case DatePickerMode.Date:
                        dateTimeControl = new CalendarDatePicker()
                        {
                            Date = DateTime.Today,
                            HorizontalAlignment = HorizontalAlignment.Stretch,
                            Margin          = new Thickness(0, 5, 0, 0),
                            PlaceholderText = "Select a date",
                            Name            = controlName + Constants.DATA_CONTROL_IDENTIFIER
                        };
                        break;

                    case DatePickerMode.Time:
                        dateTimeControl = new TimePicker()
                        {
                            Time = DateTime.Now.TimeOfDay,
                            HorizontalAlignment = HorizontalAlignment.Stretch,
                            Margin = new Thickness(0, 5, 0, 0),
                            Name   = controlName + Constants.DATA_CONTROL_IDENTIFIER
                        };
                        break;

                    case DatePickerMode.DateAndTime:
                        throw new Base.Exceptions.NotSupportedException("DateTime combination is not supported.");

                    default:
                        throw new Base.Exceptions.NotSupportedException("Not supported DatePickerMode.");
                    }

                    Grid.SetRow(dateTimeControl as FrameworkElement, 1);

                    (control as Grid).Children.Add(dateTimeControl);

                    break;

                case PropertyType.notImplementedYet:
                    control = new Grid()
                    {
                        Background = new SolidColorBrush(Colors.Red),
                        Margin     = new Thickness(10),
                        Height     = 25
                    };
                    break;

                default:
                    throw new NotSupportedPropertyTypeException("Not supported PropertyType.");
                }
            }

            RelativePanel.SetAlignLeftWithPanel(control, true);
            RelativePanel.SetAlignRightWithPanel(control, true);

            AddControlUnder(control, ref previousControl);

            return(control);
        }
        public static void RegisterDataProvider <T>(this ObjectListView listView, Func <T> dataProvider, UIModule parentModule, string suffix = null)
        {
            if (listView.ContextMenuStrip == null)
            {
                listView.ContextMenuStrip = new ContextMenuStrip();
            }
            var types = WinFwkHelper.GetDerivedTypes(typeof(AbstractDataUICommand <T>));

            foreach (var type in types)
            {
                var command = Activator.CreateInstance(type, null) as AbstractDataUICommand <T>;
                command.InitBus(parentModule.MessageBus);
                command.SetMasterModule(parentModule);
                command.InitDataProvider(new UIDataProviderAdapter <T>(dataProvider));
                string menuItemText = command.ToolTip;
                if (suffix != null)
                {
                    menuItemText += " (" + suffix + ")";
                }
                var menuItem = new ToolStripMenuItem(menuItemText);
                menuItem.Image = command.Icon;
                listView.ContextMenuStrip.Items.Add(menuItem);
                menuItem.Click += (o, e) => OnMenuItemClick(command, dataProvider);
            }
        }