예제 #1
0
        public TextDialog(IText text, SmallPortraitId?portraitId = null, int depth = 0) : base(DialogPositioning.Top, depth)
        {
            On <DismissMessageEvent>(_ => Close());
            On <UiLeftClickEvent>(e => { Close(); e.Propagating = false; });
            On <UiRightClickEvent>(e => { Close(); e.Propagating = false; });
            On <CloseWindowEvent>(e => Close());

            var textSection = new UiText(text);
            var padding     = new Padding(textSection, 3, 7);

            UiElement content;

            if (portraitId.HasValue)
            {
                var portrait = new FixedSize(36, 38,
                                             new ButtonFrame(new UiSpriteElement <SmallPortraitId>(portraitId.Value))
                {
                    State   = ButtonState.Pressed,
                    Padding = 0
                });
                content = new HorizontalStack(new CentreContent(portrait), padding);
            }
            else
            {
                content = padding;
            }

            var stack = new FixedWidth(320, content);

            AttachChild(new DialogFrame(stack)
            {
                Background = DialogFrameBackgroundStyle.DarkTint
            });
        }
        //TODO: Move crosshair to here
        public HotbarScreen()
        {
            //Init the hotbar
            Hotbar         = new UiImage(this, new Point(0, 0), new Point(5, 5), "textures/ui/hotbar_gui");
            Hotbar.size    = new Point(Hotbar.image.Width, Hotbar.image.Height);
            Hotbar.rawSize = Hotbar.size;
            Hotbar.UV      = new Vector4(0, 0, 0.3515625f, 0.0390625f);
            AddComponent(Hotbar);

            //init the items
            for (int i = 0; i < 9; i++)
            {
                items[i]         = new ItemImage(this, 0, 0, 64, 64);
                items[i].rawSize = new Point(16, 16);
                AddComponent(items[i]);
            }

            //init the selection dot
            Selected         = new UiImage(this, new Point(0, 0), new Point(5, 5), "textures/ui/hotbar_gui");
            Selected.size    = new Point(Selected.image.Width, Selected.image.Height);
            Selected.rawSize = Selected.size;
            Selected.UV      = new Vector4(0, 0.0625f, 0.04296875f, 0.10546875f);
            AddComponent(Selected);

            //init the crosshair
            CrosshairX = new UiImage(this, Point.Zero, new Point(CrossHairWidth, CrossHairThickness));
            CrosshairY = new UiImage(this, Point.Zero, new Point(CrossHairThickness, CrossHairWidth));
            AddComponent(CrosshairX);
            AddComponent(CrosshairY);

            HoverText = new UiText(this, Point.Zero, "");
            AddComponent(HoverText);
        }
예제 #3
0
    public NumericPromptDialog(IText text, int min, int max, int depth = 0) : base(DialogPositioning.Center, depth)
    {
        On <CloseWindowEvent>(e => Close());

        var textSection = new UiText(text);
        var slider      = new Slider(() => Value, x => Value = x, min, max);
        var button      = new Button(Base.SystemText.MsgBox_OK).OnClick(Close);

        Value = min;

        // 30
        var stack = new VerticalStack(
            new ButtonFrame(
                new HorizontalStack(
                    textSection,
                    new Spacing(0, 31)))
        {
            State = ButtonState.Pressed
        },
            new Spacing(0, 5),
            slider,
            new Spacing(0, 5),
            button,
            new Spacing(186, 0));

        AttachChild(new DialogFrame(stack)
        {
            Background = DialogFrameBackgroundStyle.MainMenuPattern
        });
    }
        public void OnLabelEdit(string text)
        {
            Tokenizer tokenizer = Tokenizer.Tokenize(text);

            if (tokenizer.HasError())
            {
                popup.Set("err", defaultValue.gameObject, tokenizer.GetErrorString()); return;
            }
            Token token = Token.None;

            switch (tokenizer.tokens.Count)
            {
            case 0: break;

            case 1: token = tokenizer.tokens[0]; break;

            default: token = new Token(text); break;
            }
            cHeader.columnSetting.data.label = token;
            object result = token.Resolve(tokenizer, uds.data);

            if (tokenizer.HasError())
            {
                popup.Set("err", defaultValue.gameObject, tokenizer.GetErrorString()); return;
            }
            string resultText = result?.ToString() ?? "";

            UiText.SetText(cHeader.gameObject, resultText);
            popup.Hide();
        }
예제 #5
0
    //自动设置对话框文字、长度、背景宽度
    private void SetDialogText(UiText text, UiImage dialogBg, string str)
    {
        var dialogAdd = dialogBg.rectTransform.sizeDelta.x - text.rectTransform.sizeDelta.x;

        //得到单行文字宽度
        Font font     = text.font;
        int  fontsize = text.fontSize;

        font.RequestCharactersInTexture(str, fontsize, FontStyle.Normal);
        float width = 0f;

        for (int i = 0; i < str.Length; i++)
        {
            font.GetCharacterInfo(str[i], out CharacterInfo characterInfo, fontsize);
            width += characterInfo.advance;
        }

        //默认是显示2行的
        width = width / 2;

        var txtSize = text.rectTransform.sizeDelta;

        if (txtSize.x < width)
        {
            txtSize.x = width;
            text.rectTransform.sizeDelta = txtSize;

            var dialogSize = dialogBg.rectTransform.sizeDelta;
            dialogSize.x = width + dialogAdd;
            dialogBg.rectTransform.sizeDelta = dialogSize;
        }
        text.text = str;
    }
예제 #6
0
파일: Main2.cs 프로젝트: SariSultan/RMS
        private void LangComboBox_DropDownItemClicked(object sender, RibbonItemEventArgs e)
        {
            ConfigurationHelper.UpdateLanguage(e.Item.Text);
            string LangCheck = ConfigurationHelper.GetLanguage();

            if (!LangCheck.Contains("ERROR"))
            {
                if (LangCheck.ToUpper() == "ARABIC")
                {
                    System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("ar-JO");
                    this.ribbon1.RightToLeft = RightToLeft.Yes;
                    this.RightToLeft         = RightToLeft.Yes;
                }
                else
                {
                    System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en");
                    this.ribbon1.RightToLeft = RightToLeft.No;
                    this.RightToLeft         = RightToLeft.No;
                }
            }

            UiText.TranslateUiText();
            MsgTxt.TranslateMsgsTxt();
            FormsNames.TranslateFormsNames();
            TranslateUI();
            this.Refresh();
        }
예제 #7
0
    protected override void Awake()
    {
        base.Awake();

        var text = transform.Find(TextName);

#if UNITY_EDITOR
        var img = transform.GetComponent <UiImage>();
        if (img == null)
        {
            img = gameObject.AddComponent <UiImage>();
        }
        img.Alpha = 0;

        if (text == null)
        {
            var textObj = new GameObject(TextName);
            text = textObj.transform;
            text.SetParent(transform, false);
            _text           = textObj.AddComponent <UiText>();
            _text.alignment = TextAnchor.MiddleCenter;
            _text.text      = TextName;

            var rt = _text.GetComponent <RectTransform>();
            rt.anchorMin        = new Vector2(0, 0);
            rt.anchorMax        = new Vector2(1, 1);
            rt.anchoredPosition = Vector2.zero;
            rt.sizeDelta        = Vector2.zero;
        }
#endif
        _text             = text.GetComponent <UiText>();
        _textDefaultColor = _text.color;
    }
예제 #8
0
        protected override void OnEnable()
        {
            base.OnEnable();
            t    = new Texture2D(30, 20);
            text = target as UiText;


            //var font = AssetDatabase.LoadAssetAtPath<Font>("Assets/res/ui/fonts/default.ttf");
            //text.font = font;
        }
 public void SetFieldType(int index)
 {
     // initial value is for custom text
     if (index == 0)
     {
         if (!SetFieldTypeText(UiText.GetText(fieldType.gameObject)))
         {
             return;
         }
     }
     else if (index >= 1 && columnTypes[index - 1].uiField != null)
     {
         cHeader.columnSetting.data.columnUi = new Token(columnTypes[index - 1].uiField.name);
     }
     uds.RefreshRowAndColumnUi();
 }
예제 #10
0
        public void RefreshDebug()
        {
            if (!debugVisibleObject)
            {
                return;
            }
            Vector3 p = astar.maze.GetGroundPosition(coord), u = Vector3.up * .125f;

            debugVisibleObject.transform.position = p + u;
            bool   isVisible = visMap[coord];
            string text      = (_f < 0 && _g < 0)
                                ? coord.ToString()
                                : $"{coord}\nf:{_f}\ng:{_g}\n{_edge}";

            UiText.SetText(debugVisibleObject, text);
            UiText.SetColor(debugVisibleObject, isVisible ? Color.white : Color.black);
        }
예제 #11
0
        public StatusBar() : base(DialogPositioning.StatusBar)
        {
            On <HoverTextEvent>(e => _hoverSource.Source             = e.Source);
            On <DescriptionTextEvent>(e => _descriptionSource.Source = e.Source);

            _sprite       = AttachChild(new UiSpriteElement(Base.UiBackground.SLAB));
            _sprite.SubId = 1;
            _portraits    = new StatusBarPortrait[MaxPortraits];
            for (int i = 0; i < _portraits.Length; i++)
            {
                _portraits[i] = new StatusBarPortrait(i);
                AttachChild(_portraits[i]);
            }

            var hoverText       = new UiText(_hoverSource);
            var descriptionText = new UiText(_descriptionSource);

            _hoverTextContainer       = AttachChild(new FixedPosition(new Rectangle(181, 196, 177, 10), hoverText));
            _descriptionTextContainer = AttachChild(new FixedPosition(new Rectangle(181, 208, 177, 30), descriptionText));
        }
예제 #12
0
        public override void OnInspectorGUI()
        {
            text = target as UiText;
            serializedObject.Update();


            if (GUILayout.Button("AddOutLine"))
            {
                text.AddOutLine();
                DoDirty();
            }
            if (GUILayout.Button("RemoveOutLine"))
            {
                text.RemoveOutLine();
                DoDirty();
            }
            serializedObject.ApplyModifiedProperties();

            base.OnInspectorGUI();
        }
예제 #13
0
 public void RefreshColumnText(int column, ITokenErrLog errLog)
 {
     for (int row = 0; row < contentRectangle.childCount; ++row)
     {
         GameObject fieldUi = contentRectangle.GetChild(row).GetChild(column).gameObject;
         object     value   = data.RefreshValue(row, column, errLog);
         if (errLog.HasError())
         {
             return;
         }
         if (value != null)
         {
             UiText.SetText(fieldUi, value.ToString());
             //sb.Append(value.ToString() + ", ");
         }
         else
         {
             UiText.SetText(fieldUi, "");
         }
     }
 }
예제 #14
0
    public void GoalCheck(GameObject inventoryObject)
    {
        if (idolCreator.idols == null)
        {
            return;
        }
        int unclaimedIdolCount = idolCreator.CountUnclaimedIdols();

        //Show.Log("checking..."+unclaimedIdolCount);
        if (unclaimedIdolCount > 0)
        {
            return;
        }
        nextLevelButton.SetActive(true);
        timer.Pause();
        LevelState lvl = levels.Find(l => l.stage == maze.stage);

        if (lvl == null)
        {
            throw new Exception("level not properly initialized");
        }
        int  t          = timer.GetDuration();
        bool firstTime  = lvl.bestTime == 0;
        bool betterTime = t < lvl.bestTime;

        if (firstTime || betterTime)
        {
            lvl.bestTime = t;
        }
        if (betterTime)
        {
            UiText.SetColor(timer.gameObject, Color.green);
        }
        else if (!firstTime)
        {
            UiText.SetColor(timer.gameObject, Color.gray);
        }
        bestTimeLabel.text = "best time: " + GameTimer.TimingToString(lvl.bestTime, true);
        bestTimeLabel.gameObject.SetActive(true);
    }
 // Start is called before the first frame update
 void Start()
 {
     text = GameObject.Find("scoredisplay").GetComponent <UiText>();//get the score from the scoredisplay object
 }
예제 #16
0
    public void LevelGenerate(LevelState lvl)
    {
        Team      team      = Global.GetComponent <Team>();
        EventBind checkGoal = new EventBind(this, nameof(GoalCheck));

        if (lvl == null)
        {
            lvl                  = new LevelState();
            lvl.stage            = maze.stage;
            lvl.seed             = random.Seed;
            lvl.idolsDistributed = idolCreator.idolsDistributed;
            if (inventory.GetItems() != null)
            {
                lvl.idolInventory = CodeConvert.Stringify(inventory.GetItems().ConvertAll(go => {
                    Idol t = go.GetComponent <Idol>(); return(t ? t.intMetaData : null);
                }));
            }
            else
            {
                lvl.idolInventory = "";
            }
            lvl.variables = CodeConvert.Stringify(mainDictionaryKeeper.Dictionary);
            lvl.allies    = CodeConvert.Stringify(team.members.ConvertAll(m => npcCreator.npcs.FindIndex(n => n.gameObject == m)));
            levels.Add(lvl);
        }
        else
        {
            Tokenizer tokenizer = new Tokenizer();
            // check if level is valid
            if (levels.IndexOf(lvl) < 0)
            {
                throw new Exception("TODO validate the level plz!");
            }
            // set allies
            int[] allies; CodeConvert.TryParse(lvl.allies, out allies, null, tokenizer);
            team.Clear();
            team.AddMember(firstPlayer);
            for (int i = 0; i < allies.Length; ++i)
            {
                int index = allies[i];
                if (index < 0)
                {
                    continue;
                }
                team.AddMember(npcCreator.npcs[index].gameObject);
            }
            // clear existing idols
            idolCreator.Clear();
            // reset inventory to match start state
            inventory.RemoveAllItems();
            int[][] invToLoad;
            CodeConvert.TryParse(lvl.idolInventory, out invToLoad, null, tokenizer);
            //Debug.Log(Show.Stringify(invToLoad,false));
            Vector3 playerLoc = Global.GetComponent <CharacterControlManager>().localPlayerInterfaceObject.transform.position;
            for (int i = 0; i < invToLoad.Length; ++i)
            {
                int[] t = invToLoad[i];
                if (t == null || t.Length == 0)
                {
                    continue;
                }
                GameObject idol = idolCreator.CreateIdol(t[0], t[1], checkGoal);
                idol.transform.position = playerLoc + Vector3.forward;
                inventory.AddItem(idol);
            }
            // set stage
            maze.stage = lvl.stage;
            // set seed
            random.Seed = lvl.seed;
            // set variables
            HashTable_stringobject d = mainDictionaryKeeper.Dictionary;
            CodeConvert.TryParse(lvl.variables, out d, null, tokenizer);
            // set
        }
        MarkTouchdown.ClearMarkers();
        clickToMove.ClearAllWaypoints();
        seedLabel.text = "level " + maze.stage + "." + Convert.ToBase64String(BitConverter.GetBytes(random.Seed));
        maze.Generate(random);
        Discovery.ResetAll();
        idolCreator.Generate(checkGoal);
        int len = Mathf.Min(maze.floorTileNeighborHistogram[2], idolCreator.idolMaterials.Count);

        npcCreator.GenerateMore(len);
        if (testingPickups)
        {
            idolCreator.GenerateMoreIdols(checkGoal);
        }
        // TODO maze should have a list of unfilled tiles sorted by weight
        for (int i = 0; i < npcCreator.npcs.Count; ++i)
        {
            maze.PlaceObjectOverTile(npcCreator.npcs[i].transform, maze.floorTiles[maze.floorTileNeighborHistogram[1] + i]);
        }
        team.AddMember(firstPlayer);
        maze.PlaceObjectOverTile(team.members[0].transform, maze.floorTiles[maze.floorTiles.Count - 1]);
        Vector3 pos = team.members[0].transform.position;

        for (int i = 0; i < team.members.Count; ++i)
        {
            team.members[i].transform.position = pos;
            CharacterMove cm = team.members[i].GetComponent <CharacterMove>();
            if (cm != null)
            {
                cm.SetAutoMovePosition(pos);
                cm.MoveForwardMovement = 0;
                cm.StrafeRightMovement = 0;
            }
        }
        UiText.SetColor(timer.gameObject, Color.white);
        timer.Start();
        GoalCheck(null);
        nextLevelButton.SetActive(false);
        bestTimeLabel.gameObject.SetActive(false);
    }
예제 #17
0
        public GameObject UpdateRowData(DataSheetRow rObj, RowData rowData, float yPosition = float.NaN)
        {
            object[]      columns   = rowData.columns;
            Vector2       rowCursor = Vector2.zero;
            RectTransform rect;
            // remove all columns from the row (probably temporarily)
            List <GameObject> unusedColumns = new List <GameObject>();

            for (int i = 0; i < rObj.transform.childCount; ++i)
            {
                GameObject fieldUi = rObj.transform.GetChild(i).gameObject;
                if (fieldUi == null)
                {
                    throw new Exception("a null child in the row? wat");
                }
                unusedColumns.Add(fieldUi);
            }
            while (rObj.transform.childCount > 0)
            {
                rObj.transform.GetChild(rObj.transform.childCount - 1).SetParent(null, false);
            }
            TokenErrorLog errLog = new TokenErrorLog();

            for (int c = 0; c < data.columnSettings.Count; ++c)
            {
                Udash.ColumnSetting colS    = data.columnSettings[c];
                GameObject          fieldUi = null;
                string columnUiName         = colS.data.columnUi.ResolveString(errLog, rowData.obj);
                if (columnUiName == null)
                {
                    string errorMessage = "could not resolve column UI name from " + colS.data.columnUi + "\n" + errLog.GetErrorString();
                    Show.Log(errorMessage);
                    columnUiName = colS.data.columnUi.ResolveString(errLog, rowData.obj);
                    throw new Exception(errorMessage);
                }
                // check if there's a version of it from earlier
                for (int i = 0; i < unusedColumns.Count; ++i)
                {
                    if (unusedColumns[i].name.StartsWith(columnUiName))
                    {
                        fieldUi = unusedColumns[i];
                        unusedColumns.RemoveAt(i);
                        break;
                    }
                }
                // otherwise create it
                if (fieldUi == null)
                {
                    GameObject prefab = uiPrototypes.GetElement(columnUiName);
                    if (prefab == null)
                    {
                        columnUiName = colS.data.columnUi.ResolveString(errLog, rowData.obj);
                        throw new Exception("no such prefab \"" + columnUiName + "\" in data sheet initialization script. valid values: [" +
                                            uiPrototypes.transform.JoinToString() + "]\n---\n" + colS.data.columnUi + "\n---\n" + columnSetup);
                    }
                    fieldUi = Instantiate(prefab);
                }

                if (colS.data.onClick.IsSyntax)
                {
                    ClickableScriptedCell clickable = fieldUi.GetComponent <ClickableScriptedCell>();
                    UiClick.ClearOnClick(fieldUi);
                    if (fieldUi != null)
                    {
                        Destroy(clickable);
                    }
                    clickable = fieldUi.AddComponent <ClickableScriptedCell>();
                    clickable.Set(rowData.obj, colS.data.onClick);
                    clickable.debugMetaData = colS.data.onClick.StringifySmall();
                    if (!UiClick.AddOnButtonClickIfNotAlready(fieldUi, clickable, clickable.OnClick))
                    {
                        UiClick.AddOnPanelClickIfNotAlready(fieldUi, clickable, clickable.OnClick);
                    }
                }

                fieldUi.SetActive(true);
                fieldUi.transform.SetParent(rObj.transform, false);
                fieldUi.transform.SetSiblingIndex(c);
                object value = columns[c];
                if (value != null)
                {
                    UiText.SetText(fieldUi, value.ToString());
                }
                else
                {
                    UiText.SetText(fieldUi, "");
                }
                rect = fieldUi.GetComponent <RectTransform>();
                rect.anchoredPosition = rowCursor;
                float w = rect.sizeDelta.x;
                if (colS.data.widthOfColumn > 0)
                {
                    w = colS.data.widthOfColumn;
                    rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, w);
                }
                rowCursor.x += w * rt.localScale.x;
            }
            for (int i = 0; i < unusedColumns.Count; ++i)
            {
                Destroy(unusedColumns[i]);
            }
            unusedColumns.Clear();
            rect = rObj.GetComponent <RectTransform>();
            rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, rowCursor.x);
            rect.transform.SetParent(contentRectangle, false);
            if (!float.IsNaN(yPosition))
            {
                //rect.anchoredPosition = new Vector2(0, -yPosition);
                //rect.localPosition = new Vector2(0, -yPosition);
                rObj.LocalPosition = new Vector2(0, -yPosition);
            }
            return(rObj.gameObject);
        }
예제 #18
0
        public void RefreshHeaders()
        {
            if (headerRectangle == null)
            {
                return;
            }
            Vector2 cursor = Vector2.zero;
            // put old headers aside. they may be reused.
            List <GameObject> unusedHeaders = new List <GameObject>();

            for (int i = 0; i < headerRectangle.childCount; ++i)
            {
                GameObject header = headerRectangle.GetChild(i).gameObject;
                if (header != null)
                {
                    unusedHeaders.Add(header);
                }
            }
            while (headerRectangle.childCount > 0)
            {
                Transform t = headerRectangle.GetChild(headerRectangle.childCount - 1);
                t.SetParent(null, false);
            }
            errLog.ClearErrors();
            for (int i = 0; i < data.columnSettings.Count; ++i)
            {
                Udash.ColumnSetting colS   = data.columnSettings[i];
                GameObject          header = null;
                string headerObjName       = colS.data.headerUi.ResolveString(errLog, this);
                // check if the header we need is in the old header list
                object headerTextResult = colS.data.label.Resolve(errLog, data);
                if (errLog.HasError())
                {
                    popup.Set("err", null, errLog.GetErrorString()); return;
                }
                string headerTextString = headerTextResult?.ToString() ?? null;
                for (int h = 0; h < unusedHeaders.Count; ++h)
                {
                    GameObject hdr = unusedHeaders[h];
                    if (hdr.name.StartsWith(headerObjName) && UiText.GetText(hdr) == headerTextString)
                    {
                        header = hdr;
                        unusedHeaders.RemoveAt(h);
                        break;
                    }
                }
                if (header == null)
                {
                    GameObject headerObjectPrefab = uiPrototypes.GetElement(headerObjName);
                    header      = Instantiate(headerObjectPrefab);
                    header.name = header.name.SubstringBeforeFirst("(", headerObjName.Length) + "(" + colS.data.label + ")";
                    UiText.SetText(header, headerTextString);
                }
                ColumnHeader ch = header.GetComponent <ColumnHeader>();
                if (ch != null)
                {
                    ch.columnSetting = colS;
                }
                header.SetActive(true);
                header.transform.SetParent(headerRectangle, false);
                header.transform.SetSiblingIndex(i);
                RectTransform rect = header.GetComponent <RectTransform>();
                rect.anchoredPosition = cursor;
                float w = rect.sizeDelta.x;
                if (colS.data.widthOfColumn > 0)
                {
                    w = colS.data.widthOfColumn;
                    rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, w);
                }
                else
                {
                    colS.data.widthOfColumn = w;                     // if the width isn't set, use the default width of the column header
                }
                cursor.x += w * rt.localScale.x;
            }
            contentAreaSize.x = cursor.x;
            for (int i = 0; i < unusedHeaders.Count; ++i)
            {
                GameObject header = unusedHeaders[i];
                Destroy(header);
            }
            unusedHeaders.Clear();
            contentRectangle.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, cursor.x);
            popup.Hide();
        }
 // Start is called before the first frame update
 void Start()
 {
     time = GameObject.Find("scoredisplay").GetComponent <UiText>();
 }
예제 #20
0
        static void Main()
        {
            try
            {
                /*  string resource = "Calcium_RMS.System.Windows.Forms.Ribbon35.dll";
                 * using (Stream stm = Assembly.GetExecutingAssembly().GetManifestResourceStream(resource))
                 * {
                 *    byte[] ba = new byte[(int)stm.Length];
                 *    stm.Read(ba, 0, (int)stm.Length);
                 *    ribbon = Assembly.Load(ba);
                 * }
                 * AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
                 */
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                try
                {
                    TestSqlService();
                    Helper.SetConnectionString();
                    if (!Helper.TestConnectionString())
                    {
                        if (Helper.__ConnectionString == "ERROR:File Not Exist")
                        {
                            string Ret = MessageBox.Show("Cannot Connect To Database \n If This Is Your First Run For the Program Press Yes To Create New DataBase \n WARNING: if you already have a database click no to protect your database from being removed", "DATABASE", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2).ToString();
                            if (Ret == "Yes")
                            {
                                try
                                {
                                    string ExecDir  = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
                                    string DBEmpDir = @"\RMSV1.1EmptyDB";
                                    File.Copy(ExecDir + DBEmpDir + @"\DB.mdf", ExecDir + @"\DataBase.mdf");
                                    File.Copy(ExecDir + DBEmpDir + @"\DB_log.ldf", ExecDir + @"\DataBase_log.ldf");
                                    string ConnStringnew = @"Data Source=.\SQLEXPRESS;AttachDbFilename=" + ExecDir + @"\Database.mdf;Integrated Security=True;User Instance=True";
                                    ConfigurationHelper.UpdateConnString(ConnStringnew);
                                    MessageBox.Show("New DataBase Created Successfully, Application will restart now default logins \n Username : Admin \n Password: Admin \n note: username and password are not case sensitive", "Created succesfully", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    Application.Restart();
                                }
                                catch (Exception ex)
                                {
                                    MessageBox.Show("It seems you have a working database\nTo prevent your data loss the program will not continue\nFailed To Create New Database, Please Contact System Administrator \n" + ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    Application.ExitThread();
                                    Application.Exit();
                                }
                            }
                            else
                            {
                                Application.ExitThread();
                                Application.Exit();
                            }
                        }
                        else
                        {
                            MessageBox.Show("Cannot Connect To Database Error In Connection String", "DataBase Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            Application.Run(new ConnStringFrm());
                        }
                    }
                    else
                    {
                        Application.Run(new SplashFrm());
                        //DateTime __StartTime = DateTime.Now;
                        // Helper.SetConnectionString();
                        // Security.V1.ActivationCheck.TrialCheck();
                        string LangCheck;
                        LangCheck = ConfigurationHelper.GetReceiptLanguage();
                        if (!LangCheck.Contains("ERROR"))
                        {
                            if (LangCheck.ToUpper() == "ARABIC")
                            {
                                System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("ar-JO");
                                Reports.ReportsHelper.ReceiptRTL = true;
                                ReceiptName.TranslateReceiptText();
                                ReceiptText.TranslateReceiptText();
                                System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en");
                                //TRANSLATE RECIEPT
                            }
                            else
                            {
                                Reports.ReportsHelper.ReceiptRTL = false;
                                ReceiptName.TranslateReceiptText();
                                ReceiptText.TranslateReceiptText();
                            }
                        }
                        else
                        {
                            Reports.ReportsHelper.ReceiptRTL = false;
                            ReceiptName.TranslateReceiptText();
                            ReceiptText.TranslateReceiptText();
                        }
                        LangCheck = ConfigurationHelper.GetLanguage();
                        if (!LangCheck.Contains("ERROR"))
                        {
                            if (LangCheck.ToUpper() == "ARABIC")
                            {
                                System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("ar-JO");
                            }
                        }
                        UiText.TranslateUiText();
                        MsgTxt.TranslateMsgsTxt();
                        FormsNames.TranslateFormsNames();

                        //TimeSpan __TimeSpan = DateTime.Now.Subtract(__StartTime);
                        //string __ET = string.Format("{0:00}.{1:00}.{2:00}:{3:000}", __TimeSpan.Hours, __TimeSpan.Minutes, __TimeSpan.Seconds, __TimeSpan.Milliseconds);
                        //MessageBox.Show("ET=" + __ET);
                        Application.Run(new login());
                        int x = 100;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Application.Exit();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error message \n" + ex.ToString());
            }
        }
예제 #21
0
    void Update()
    {
        if (visionParticle != null)
        {
            if (characterMover.JumpButtonTimed > 0 && !visionParticle.isPlaying)
            {
                visionParticle.Play();
            }
            else if (characterMover.JumpButtonTimed == 0 && visionParticle.isPlaying)
            {
                visionParticle.Stop();
            }
        }
        Coord mapSize = maze.Map.GetSize();

        if (mapAstar == null)
        {
            mapAstar = new Map2dAStar(() => canJump, maze, discovery.vision, _t, prefab_debug_astar);
        }
        mapAstar.UpdateMapSize();
        Vector3 p    = _t.position;
        Coord   here = maze.GetCoord(p);

        if (follower.waypoints.Count > 0)
        {
            Coord there = maze.GetCoord(follower.waypoints[0].positon);
            if (here == there)
            {
                follower.NotifyWayPointReached();
            }
        }
        List <Coord> moves = mapAstar.Moves(here, canJump);

        if (textOutput != null)
        {
            UiText.SetText(textOutput, here.ToString() + ":" + (p - maze.transform.position) + " " + moves.JoinToString(", "));
        }
        if (useVisionParticle && visionParticle)
        {
            timer -= Time.deltaTime;
            if (timer <= 0)
            {
                mapSize.ForEach(co => {
                    if (discovery.vision[co])
                    {
                        Vector3 po = maze.GetPosition(co);
                        po.y       = _t.position.y;
                        visionParticle.transform.position = po;
                        visionParticle.Emit(1);
                    }
                });
                timer = .5f;
            }
        }
        switch (aiBehavior)
        {
        case AiBehavior.RandomLocalEdges:
            if (!characterMover.IsAutoMoving())
            {
                Coord c = moves[Random.Next(moves.Count)];
                characterMover.SetAutoMovePosition(MoveablePosition(c, p));
            }
            break;

        case AiBehavior.RandomInVision:
            if (mapAstar.goal == here)
            {
                if (mapAstar.RandomVisibleNode(out Coord there, here))
                {
                    //Debug.Log("startover #");
                    //Debug.Log("goal " + there+ " "+astar.IsFinished());
                }
                else
                {
                    mapAstar.RandomNeighborNode(out there, here);
                }
                mapAstar.Start(here, there);
            }
            else
            {
                // iterate astar algorithm
                if (!mapAstar.IsFinished())
                {
                    mapAstar.Update();
                }
                else if (mapAstar.BestPath == null)
                {
                    //Debug.Log("f" + astar.IsFinished() + " " + astar.BestPath);
                    mapAstar.Start(here, here);
                    //Debug.Log("startover could not find path");
                }
                if (mapAstar.BestPath != null)
                {
                    if (mapAstar.BestPath != currentBestPath)
                    {
                        currentBestPath = mapAstar.BestPath;
                        List <Coord> nodes = new List <Coord>();
                        Coord        c     = mapAstar.start;
                        nodes.Add(c);
                        for (int i = currentBestPath.Count - 1; i >= 0; --i)
                        {
                            c = mapAstar.NextNode(c, currentBestPath[i]);
                            nodes.Add(c);
                        }
                        //Debug.Log(currentBestPath.JoinToString(", "));
                        indexOnBestPath = nodes.IndexOf(here);
                        if (indexOnBestPath < 0)
                        {
                            mapAstar.Start(here, mapAstar.goal);
                            //Debug.Log("startover new better path");
                        }
                        Vector3 pos = p;
                        follower.ClearWaypoints();
                        for (int i = 0; i < currentBestPath.Count; ++i)
                        {
                            pos = MoveablePosition(nodes[i + 1], pos);
                            //pos.y += follower.CharacterHeight;
                            //Show.Log(i + " " + nodes.Count + " " + currentBestPath.Count + " " + (currentBestPath.Count - i - 1));
                            MazeAStar.EdgeMoveType moveType = MazeAStar.GetEdgeMoveType(currentBestPath[currentBestPath.Count - i - 1]);
                            switch (moveType)
                            {
                            case MazeAStar.EdgeMoveType.Walk: follower.AddWaypoint(pos, false); break;

                            case MazeAStar.EdgeMoveType.Fall: follower.AddWaypoint(pos, false, 0, true); break;

                            case MazeAStar.EdgeMoveType.Jump: follower.AddWaypoint(pos, false, characterMover.jump.fullPressDuration); break;
                            }
                        }
                        follower.SetCurrentTarget(pos);
                        follower.UpdateLine();
                        follower.doPrediction = true;
                    }
                    else
                    {
                        if (!characterMover.IsAutoMoving() && follower.waypoints.Count == 0)
                        {
                            mapAstar.Start(here, here);
                            //Debug.Log("startover new level?");
                        }
                    }
                }
            }
            break;
        }
    }
예제 #22
0
        public VisualInventorySlot(InventorySlotId slotId, IText amountSource, Func <IReadOnlyItemSlot> getSlot)
        {
            On <IdleClockEvent>(e => _frameNumber++);

            _slotId  = slotId;
            _getSlot = getSlot;
            _overlay = new UiSpriteElement(Base.CoreSprite.UiBroken)
            {
                IsActive = false
            };
            var text = new UiText(amountSource);

            if (!slotId.Slot.IsSpecial())
            {
                _size = slotId.Slot.IsBodyPart() ?
                        new Vector2(18, 18) : //16x16 surrounded by 1px borders
                        new Vector2(16, 20);
                _sprite = new UiSpriteElement(SpriteId.None);
                _button = AttachChild(new Button(new FixedPositionStack()
                                                 .Add(
                                                     new LayerStack(
                                                         _sprite,
                                                         _overlay),
                                                     1, 1, 16, 16) //16x16 surrounded by 1px borders
                                                 .Add(text, 0, 20 - 9, 16, 9))
                {
                    Padding = -1,
                    Margin  = 0,
                    Theme   = slotId.Slot.IsBodyPart()
                                ? (ButtonFrame.ThemeFunction)ButtonTheme.Default
                                : ButtonTheme.InventorySlot,

                    IsPressed = !slotId.Slot.IsBodyPart()
                }
                                      .OnHover(() => Hover?.Invoke())
                                      .OnBlur(() => Blur?.Invoke())
                                      .OnClick(() => Click?.Invoke())
                                      .OnRightClick(() => RightClick?.Invoke())
                                      .OnDoubleClick(() => DoubleClick?.Invoke())
                                      .OnButtonDown(() => ButtonDown?.Invoke()));
            }
            else
            {
                _sprite = new UiSpriteElement(
                    slotId.Slot == ItemSlotId.Gold
                        ? Base.CoreSprite.UiGold
                        : Base.CoreSprite.UiFood);

                _button = AttachChild(new Button(
                                          new VerticalStack(
                                              new Spacing(31, 0),
                                              _sprite,
                                              new UiText(amountSource)
                                              )
                {
                    Greedy = false
                })
                                      .OnHover(() => Hover?.Invoke())
                                      .OnBlur(() => Blur?.Invoke())
                                      .OnClick(() => Click?.Invoke())
                                      .OnRightClick(() => RightClick?.Invoke())
                                      .OnDoubleClick(() => DoubleClick?.Invoke())
                                      .OnButtonDown(() => ButtonDown?.Invoke()));
            }
        }
예제 #23
0
    public void RefreshImage()
    {
        if (ButtonType == EControllerBtns.None)
        {
            gameObject.SetActiveSafe(false);
            return;
        }
        if (_activeState)
        {
            gameObject.SetActiveSafe(true);
        }


        var style = InputDeviceStyle.Unknown;

        if (InputManager.Devices.Count > 0)
        {
            style = InputManager.Devices[InputManager.Devices.Count - 1].DeviceStyle;
        }

        _image     = GetComponentInChildren <UiImage>();
        _text      = GetComponentInChildren <UiText>();
        _text.text = "";
        switch (style)
        {
        case InputDeviceStyle.Unknown:
            //Pc显示方案
            var mouse = ControllerUtility.GetMouseType(ButtonType);
            if (mouse != Mouse.None)
            {
                var mouseImg = ControllerUtility.GetImageMouse(mouse);
                _image.SetSprite(EImagePath.Public, mouseImg);
            }
            else
            {
                var    key  = ControllerUtility.GetKeyBoardType(ButtonType);
                string text = "";
                var    img  = ControllerUtility.GetImageKeyboard(key, out text);
                _image.SetSprite(EImagePath.Public, img);
                _text.text = text;
            }
            break;

        case InputDeviceStyle.Ouya:
        case InputDeviceStyle.AppleMFi:
        case InputDeviceStyle.AmazonFireTV:
        case InputDeviceStyle.NVIDIAShield:
        case InputDeviceStyle.Steam:
        case InputDeviceStyle.Xbox360:
        case InputDeviceStyle.XboxOne:
        case InputDeviceStyle.Vive:
        case InputDeviceStyle.Oculus:
            //xbox 显示方案
            var imgStr = ControllerUtility.GetImageXBox(ControllerUtility.GetControlType(ButtonType));
            _image.SetSprite(EImagePath.Public, imgStr);
            break;

        case InputDeviceStyle.PlayStation2:
        case InputDeviceStyle.PlayStation3:
        case InputDeviceStyle.PlayStation4:
        case InputDeviceStyle.PlayStationVita:
        case InputDeviceStyle.PlayStationMove:
            //ps 显示方案
            var psImageStr = ControllerUtility.GetImagePlayStation(ControllerUtility.GetControlType(ButtonType));
            _image.SetSprite(EImagePath.Public, psImageStr);
            break;

        case InputDeviceStyle.NintendoNES:
        case InputDeviceStyle.NintendoSNES:
        case InputDeviceStyle.Nintendo64:
        case InputDeviceStyle.NintendoGameCube:
        case InputDeviceStyle.NintendoWii:
        case InputDeviceStyle.NintendoWiiU:
        case InputDeviceStyle.NintendoSwitch:
            //switch 显示方案
            var nintendoImageStr = ControllerUtility.GetImageNintendo(ControllerUtility.GetControlType(ButtonType));
            _image.SetSprite(EImagePath.Public, nintendoImageStr);
            break;
        }
    }
        public DebugScreen()
        {
            debugTxtLeft = new UiText(this, 5, 5, "", Color.White);
            AddComponent(debugTxtLeft);

            debugTxtRight            = new UiText(this, 5, 5, "", Color.White);
            debugTxtRight.AlignRight = true;
            AddComponent(debugTxtRight);

            profiler = new ProfilerGraphRenderer(this, 0, 0);
            AddComponent(profiler);

            visible = false;

            #region System Data
#if !CONSOLE
            //Get the system data, and cache it into the strings (you cant power off a machine, change the cpu and still be running the same apps)
            ManagementObjectSearcher videoCardInfo = new ManagementObjectSearcher("SELECT * FROM Win32_VideoController");
            ManagementObjectSearcher processorInfo = new ManagementObjectSearcher("SELECT * FROM Win32_Processor");
            ManagementObjectSearcher memoryInfo    = new ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMemory");

            //Reset RAM, CPU, GPU info
            GPUName   = "";
            CPUName   = "";
            RAMInfo   = "";
            RAMInfoGB = "";

            //Get the GPU using MonoGame APIs. If it fails, return all connected GPUs
            GPUName = GraphicsAdapter.DefaultAdapter.Description;
            if (GPUName == "" || GPUName == null)
            {
                foreach (ManagementObject obj in videoCardInfo.Get())
                {
                    //"Intel(R) HD Graphics 5500 (AdapterRAM (int32) B => GB) GB"
                    //"Name (AdapterRAM GB)"
                    GPUName += obj["Name"] + " (" + (uint.Parse(obj["AdapterRAM"].ToString()) / 1024 / 1024 / 1024) + " GB)\n";
                }
            }

            foreach (ManagementObject obj in processorInfo.Get())
            {
                //"Intel(R) Core(TM) i7-5600U CPU @ 2.60GHz (2/2; 4) (64)"
                //"Name (CoreCount/EnabledCoreCount; LogicalProcessors) (AddressWidth)"
                CPUName += obj["Name"] + " (" + obj["NumberOfCores"] + "/" + obj["NumberOfCores"]
                           + "; " + obj["NumberOfLogicalProcessors"] + ") (" + obj["AddressWidth"] + ")\n";
            }

            ulong ramCnt = 0;
            foreach (ManagementObject obj in memoryInfo.Get())
            {
                //"Samsung 4GB RAM @ 1600 MHz"
                //"Manufacturer MemoryType => GB RAM @ Speed MHz"
                ramCnt += ulong.Parse(obj["Capacity"].ToString()) / 1024 / 1024;
            }
            RAMInfo   = ramCnt.ToString();
            RAMInfoGB = (ramCnt / 1024).ToString();

            if (GPUName == "" || GPUName == null)
            {
                GPUName = "Unidentified GPU";
            }
            if (CPUName == "" || CPUName == null)
            {
                CPUName = "Unidentified CPU";
            }
            if (RAMInfo == "" || RAMInfo == null)
            {
                RAMInfo = "0";
            }
            if (RAMInfoGB == "" || RAMInfoGB == null)
            {
                RAMInfoGB = "0";
            }
#endif
            #endregion
        }