public CheckBox(BaseControl owner)
     : base(owner)
 {
     Group  = 0;
     fImage = NWResourceManager.LoadImage(MainWindow.Screen, "itf/Check.tga", Colors.None);
     Height = 20;
 }
Exemple #2
0
        private void LoadLangs()
        {
            var f = new FileStream(NWResourceManager.GetAppPath() + LANGS_XML, FileMode.Open);

            try {
                XmlDocument xmlDocument = new XmlDocument();
                xmlDocument.Load(f);

                XmlNode root = xmlDocument.DocumentElement;
                if (!root.Name.Equals("langs"))
                {
                    throw new Exception("Its not langs file!");
                }

                XmlNodeList nl = root.SelectNodes("lang");
                for (int i = 0; i < nl.Count; i++)
                {
                    XmlNode el = nl[i];
                    try {
                        string name   = (el.Attributes["name"].InnerText);
                        string prefix = (el.Attributes["prefix"].InnerText);

                        fLangs.Add(new LangRec(name, prefix));
                    } catch (Exception ex) {
                        Logger.Write("Locale.loadLangs.1(): " + ex.Message);
                    }
                }
            } catch (Exception ex) {
                Logger.Write("Locale.loadLangs(): " + ex.Message);
            }
        }
Exemple #3
0
        public int AddImage(string fileName, int transColor, bool transDefault)
        {
            try {
                BaseImage img = NWResourceManager.LoadImage(fScreen, fileName, transColor);
                if (img != null)
                {
                    if (transDefault)
                    {
                        img.SetTransDefault();
                    }

                    int result = fImages.Count;
                    fImages.Add(img);

                    return(result);
                }
                else
                {
                    return(-1);
                }
            } catch (Exception ex) {
                Logger.Write("ImageList.addImage(" + fileName + "): " + ex.Message);
                return(-1);
            }
        }
        public void InitNorseDic()
        {
            try {
                Stream stm = NWResourceManager.LoadStream("Names.txt");
                using (BinaryReader bis = new BinaryReader(stm)) {
                    Parser aParser = new Parser(bis, StaticData.DefEncoding);
                    while (aParser.Token != Parser.сptEOF)
                    {
                        char token = aParser.Token;
                        if (token == Parser.сptSymbol)
                        {
                            string symName = aParser.TokenString();
                            aParser.NextToken();
                            aParser.CheckToken('=');
                            aParser.NextToken();

                            if ((symName != "femaleCount") && (symName != "maleCount"))
                            {
                                string engName = aParser.TokenString();
                                aParser.NextToken();
                                aParser.CheckToken(',');
                                aParser.NextToken();
                                string rusName = aParser.TokenString();
                                aParser.NextToken();

                                char g = symName[0];
                                //symName = symName.substring(1);
                                //TAuxUtils.StrToInt(symName);

                                DicRecord drec = new DicRecord();
                                drec.Name     = engName;
                                drec.Rus_name = rusName;

                                if (g != 'f')
                                {
                                    if (g == 'm')
                                    {
                                        Viking_m.Add(drec);
                                    }
                                }
                                else
                                {
                                    Viking_f.Add(drec);
                                }
                            }
                        }
                        else
                        {
                            aParser.NextToken();
                        }
                    }

                    aParser.Dispose();
                }
            } catch (Exception ex) {
                Logger.Write("TNWNameLib.InitNorseDic(): " + ex.Message);
            }
        }
        public MapWindow(BaseControl owner) : base(owner)
        {
            Font        = CtlCommon.SmFont;
            Width       = 656;
            Height      = 496;
            WindowStyle = new WindowStyles(WindowStyles.wsScreenCenter, WindowStyles.wsModal, WindowStyles.wsKeyPreview);
            BackDraw    = false;
            Shifted     = false;

            fImage   = NWResourceManager.LoadImage(MainWindow.Screen, "itf/MapBack.tga", Colors.None);
            fMapHint = "";
        }
        public static string GetTextFileByLang(string fileName)
        {
            string result;
            string ext = GlobalVars.nwrWin.LangExt;

            fileName = fileName + "." + ext;

            try {
                Stream stm = NWResourceManager.LoadStream(fileName);
                using (BinaryReader dis = new BinaryReader(stm)) {
                    result = StreamUtils.ReadText(dis, StaticData.DefEncoding);
                }
            } catch (Exception) {
                result = "";
            }

            return(result);
        }
Exemple #7
0
        public HeroWindow(BaseControl owner)
            : base(owner)
        {
            Font        = CtlCommon.SmFont;
            Width       = 590;
            Height      = 430;
            WindowStyle = new WindowStyles(WindowStyles.wsScreenCenter, WindowStyles.wsModal, WindowStyles.wsKeyPreview);

            fImages = new BaseImage[6];
            for (int pa = (int)SysCreature.sc_First; pa <= (int)SysCreature.sc_Last; pa++)
            {
                SysCreatureRec sc = StaticData.dbSysCreatures[pa];

                fImages[pa] = NWResourceManager.LoadImage(MainWindow.Screen, "itf/pa_" + sc.Sign + ".tga", Colors.None);
            }

            fEditBox         = new EditBox(this);
            fEditBox.Left    = (Width - 200) / 2;
            fEditBox.Top     = 35;
            fEditBox.Width   = 200;
            fEditBox.Visible = true;
        }
Exemple #8
0
        public bool SetLang(string name)
        {
            int idx = FindLang(name);

            if (idx < 0)
            {
                return(false);
            }
            else
            {
                try {
                    string prefix = LANGS_FOLDER + fLangs[idx].Prefix;
                    string f      = NWResourceManager.GetAppPath() + prefix;
                    LoadLangDB(f + "_db.xml");
                    LoadLangTexts(f + "_texts.xml");
                    LoadLangDialogs(f);
                    return(true);
                } catch (Exception) {
                    return(false);
                }
            }
        }
Exemple #9
0
        public ScrollBar(BaseControl owner)
            : base(owner)
        {
            ControlStyle.Include(ControlStyles.сsCaptureMouse);
            fKind = SBK_VERTICAL;
            fOldThumbX = -1;
            fOldThumbY = -1;
            fOldThumbPos = -1;
            fMin = 0;
            fMax = 100;
            fPos = 0;
            ThumbHeight = 17;
            ThumbWidth = 17;
            ArrowHeight = 17;
            ArrowWidth = 17;
            BaseScreen scr = MainWindow.Screen;

            fThumb = NWResourceManager.LoadImage(scr, "itf/SBThumb.tga", Colors.None);
            fHBack = NWResourceManager.LoadImage(scr, "itf/SBHBack.tga", Colors.None);
            fHArrows = NWResourceManager.LoadImage(scr, "itf/SBHArrow.tga", Colors.None);
            fVBack = NWResourceManager.LoadImage(scr, "itf/SBVBack.tga", Colors.None);
            fVArrows = NWResourceManager.LoadImage(scr, "itf/SBVArrow.tga", Colors.None);
        }
        public ListBox(BaseControl owner)
            : base(owner)
        {
            fMode                  = MODE_LIST;
            fColumnTitles          = new LBColumnTitles();
            fColumnTitles.OnChange = OnChange;
            fItems                 = new LBItemList(this, null);
            fItems.OnChange        = OnChange;
            fColumns               = 1;
            fTopIndex              = 0;
            fSelIndex              = 0;
            Options                = new LBOptions();

            ScrollBar          = new ScrollBar(this);
            ScrollBar.Min      = 0;
            ScrollBar.Max      = 100;
            ScrollBar.Pos      = 0;
            ScrollBar.OnChange = OnScroll;
            ScrollBar.Left     = Width - ScrollBar.Width;
            ScrollBar.Top      = 0;
            ScrollBar.Height   = 104;

            SelColor       = Colors.Gray;
            SelBorderColor = Colors.Gray;
            Height         = 100;
            Width          = 200;
            ItemHeight     = Font.Height + 2;
            BaseScreen scr = MainWindow.Screen;

            CheckImage  = NWResourceManager.LoadImage(scr, "itf/Check.tga", Colors.None);
            CheckHeight = (int)((int)CheckImage.Height / 3);
            CheckWidth  = (int)CheckImage.Width;

            TVBtn       = NWResourceManager.LoadImage(scr, "itf/TVBtn.tga", Colors.Black);
            LevelOffset = (int)TVBtn.Width;
        }
Exemple #11
0
        public void LoadXML(string fileName)
        {
            try {
                FileHeader header = new FileHeader();
                Clear();

                Stream @is = NWResourceManager.LoadStream(fileName);

                XmlDocument xmlDocument = new XmlDocument();
                xmlDocument.Load(@is);

                XmlNode root = xmlDocument.DocumentElement;
                if (!root.Name.Equals("RDB"))
                {
                    throw new Exception("Its not RDB!");
                }

                XmlNode vers = root.SelectSingleNode("Version");
                if (vers == null)
                {
                    //throw new RuntimeException("Not found version!");
                }

                XmlNode entries = root.SelectSingleNode("Entries");
                if (entries == null)
                {
                    //throw new RuntimeException("Not found entries!");
                }

                fEntriesCount = Convert.ToInt32(entries.Attributes["Count"].InnerText);
                fEntries      = new DataEntry[fEntriesCount];

                XmlNodeList nl = entries.ChildNodes;
                for (int i = 0; i < nl.Count; i++)
                {
                    XmlNode el = nl[i];
                    if (el.Name.Equals("Entry"))
                    {
                        string val = "";
                        try {
                            sbyte kind = DataEntry.ParseEntryKind(el.Attributes["Kind"].InnerText);
                            int   id   = Convert.ToInt32(el.Attributes["GUID"].InnerText);

                            DataEntry entry = null;
                            if (kind != DataEntry.ek_Unknown)
                            {
                                entry      = CreateEntry(kind);
                                entry.Kind = kind;
                                entry.LoadXML(el, header.Version);
                            }
                            fEntries[id] = entry;
                        } catch (Exception ex) {
                            Logger.Write("LoadXML.1(" + val + "): " + ex.Message);
                        }
                    }
                }

                Logger.Write("dbLoad(): ok");
            } catch (Exception ex) {
                Logger.Write("LoadXML(): " + ex.Message);
            }
        }
Exemple #12
0
        public MenuWindow(BaseControl owner)
            : base(owner)
        {
            fSplash = NWResourceManager.LoadImage(MainWindow.Screen, "itf/Splash.tga", Colors.None);

            int offset = 110;

            Width       = 204;
            Height      = 270 + offset;
            WindowStyle = new WindowStyles(WindowStyles.wsScreenCenter, WindowStyles.wsModal, WindowStyles.wsKeyPreview);

            NWButton tRButton = new NWButton(this);

            tRButton.Left         = 20;
            tRButton.Top          = offset + 20;
            tRButton.Width        = 164;
            tRButton.Height       = 30;
            tRButton.ImageFile    = "itf/MenuBtn.tga";
            tRButton.OnClick      = OnBtnClose;
            tRButton.OnLangChange = GlobalVars.nwrWin.LangChange;
            tRButton.LangResID    = 7;

            NWButton tRButton2 = new NWButton(this);

            tRButton2.Left         = 20;
            tRButton2.Top          = offset + 60;
            tRButton2.Width        = 164;
            tRButton2.Height       = 30;
            tRButton2.ImageFile    = "itf/MenuBtn.tga";
            tRButton2.OnClick      = OnBtnNew;
            tRButton2.OnLangChange = GlobalVars.nwrWin.LangChange;
            tRButton2.LangResID    = 1;

            NWButton tRButton3 = new NWButton(this);

            tRButton3.Left         = 20;
            tRButton3.Top          = offset + 100;
            tRButton3.Width        = 164;
            tRButton3.Height       = 30;
            tRButton3.ImageFile    = "itf/MenuBtn.tga";
            tRButton3.OnClick      = OnBtnLoad;
            tRButton3.OnLangChange = GlobalVars.nwrWin.LangChange;
            tRButton3.LangResID    = 2;

            NWButton tRButton4 = new NWButton(this);

            tRButton4.Left         = 20;
            tRButton4.Top          = offset + 140;
            tRButton4.Width        = 164;
            tRButton4.Height       = 30;
            tRButton4.ImageFile    = "itf/MenuBtn.tga";
            tRButton4.OnClick      = OnBtnSave;
            tRButton4.OnLangChange = GlobalVars.nwrWin.LangChange;
            tRButton4.LangResID    = 3;

            NWButton tRButton5 = new NWButton(this);

            tRButton5.Left         = 20;
            tRButton5.Top          = offset + 180;
            tRButton5.Width        = 164;
            tRButton5.Height       = 30;
            tRButton5.ImageFile    = "itf/MenuBtn.tga";
            tRButton5.OnClick      = OnBtnOptions;
            tRButton5.OnLangChange = GlobalVars.nwrWin.LangChange;
            tRButton5.LangResID    = 5;

            NWButton tRButton6 = new NWButton(this);

            tRButton6.Left         = 20;
            tRButton6.Top          = offset + 220;
            tRButton6.Width        = 164;
            tRButton6.Height       = 30;
            tRButton6.ImageFile    = "itf/MenuBtn.tga";
            tRButton6.OnClick      = OnBtnExit;
            tRButton6.OnLangChange = GlobalVars.nwrWin.LangChange;
            tRButton6.LangResID    = 6;
        }
        public void LoadNamesData(string fileName)
        {
            try {
                TLineKind line_kind = TLineKind.lkInf;

                using (StreamReader isr = new StreamReader(NWResourceManager.LoadStream(fileName))) {
                    string line;
                    while ((line = isr.ReadLine()) != null)
                    {
                        if (line.Length > 0 && line[0] != '/')
                        {
                            if (line[0] == '[')
                            {
                                if (line.Contains("[inf]"))
                                {
                                    line_kind = TLineKind.lkInf;
                                }
                                else
                                {
                                    if (line.Contains("[first]"))
                                    {
                                        line_kind = TLineKind.lkFirst;
                                    }
                                    else
                                    {
                                        if (line.Contains("[mid]"))
                                        {
                                            line_kind = TLineKind.lkMid;
                                        }
                                        else
                                        {
                                            if (line.Contains("[final]"))
                                            {
                                                line_kind = TLineKind.lkFinal;
                                            }
                                            else
                                            {
                                                if (line.Contains("[end]") || line.Contains("[stop]"))
                                                {
                                                    line_kind = TLineKind.lkEnd;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            else
                            {
                                if (line_kind != TLineKind.lkFirst)
                                {
                                    if (line_kind != TLineKind.lkMid)
                                    {
                                        if (line_kind == TLineKind.lkFinal)
                                        {
                                            fFinalSlabs.Add(line);
                                        }
                                    }
                                    else
                                    {
                                        fMidSlabs.Add(line);
                                    }
                                }
                                else
                                {
                                    fFirstSlabs.Add(line);
                                }
                            }
                        }
                    }
                }
            } catch (Exception ex) {
                Logger.Write("TNWNameLib.LoadData(): " + ex.Message);
            }
        }
 public static void InitCtlImages(BaseScreen screen)
 {
     CtlDecor = NWResourceManager.LoadImage(screen, "itf/ctl_decor.tga", Colors.White);
     WinBack  = NWResourceManager.LoadImage(screen, "itf/back.tga", Colors.None);
     WinDecor = NWResourceManager.LoadImage(screen, "itf/win_decor.tga", Colors.White);
 }
Exemple #15
0
        private void LoadTemplate()
        {
            Data = new FieldData();

            int[, ] varTiles = new int[StaticData.FieldHeight, StaticData.FieldWidth];
            string varFile = "/fields/" + Sign + ".var";

            if (NWResourceManager.HasStream(varFile))
            {
                try {
                    using (StreamReader isr = new StreamReader(NWResourceManager.LoadStream(varFile))) {
                        for (int y = 0; y < StaticData.FieldHeight; y++)
                        {
                            string   line  = isr.ReadLine().Trim();
                            string[] parts = line.Split(' ');

                            for (int x = 0; x < StaticData.FieldWidth; x++)
                            {
                                int @var = Convert.ToInt32(parts[x]);
                                varTiles[y, x] = @var;
                            }
                        }
                    }
                } catch (Exception ex) {
                    Logger.Write("FieldEntry.loadTemplate.2(): " + ex.Message);
                }
            }

            try {
                string tplFile = "fields/" + Sign + TemplateExt;
                using (StreamReader isr = new StreamReader(NWResourceManager.LoadStream(tplFile))) {
                    for (int y = 0; y < StaticData.FieldHeight; y++)
                    {
                        string line = isr.ReadLine();

                        for (int x = 0; x < StaticData.FieldWidth; x++)
                        {
                            char sym = line[x];

                            FDTile tile = new FDTile();
                            Data.Tiles[y, x] = tile;

                            int bg  = 0;
                            int fg  = 0;
                            int bgv = 0;
                            int fgv = 0;

                            switch (sym)
                            {
                            case '.':
                                bg = PlaceID.pid_Grass;
                                break;

                            case ',':
                                bg = PlaceID.pid_Floor;
                                break;

                            case '~':
                                bg = PlaceID.pid_Water;
                                break;

                            case '*':
                                bg = PlaceID.pid_Space;
                                break;

                            case '^':
                                bg = PlaceID.pid_Ground;
                                fg = PlaceID.pid_Mountain;
                                break;

                            case ':':
                                bg = PlaceID.pid_Floor;
                                break;

                            case 'x':
                                bg = PlaceID.pid_Ground;
                                fg = PlaceID.pid_Rock;
                                break;

                            case '+':
                                bg  = PlaceID.pid_Bifrost;
                                bgv = varTiles[y, x];
                                break;

                            case 'o':
                                bg  = PlaceID.pid_Grass;
                                fg  = PlaceID.pid_Ting;
                                fgv = varTiles[y, x];
                                break;

                            case '1':
                                bg = PlaceID.pid_cr_y;
                                break;

                            case '2':
                                bg = PlaceID.pid_cr_r;
                                break;

                            case '3':
                                bg = PlaceID.pid_cr_b;
                                break;

                            case '4':
                                bg = PlaceID.pid_cr_a;
                                break;

                            case '5':
                                bg = PlaceID.pid_cr_l;
                                break;

                            case '6':
                                bg = PlaceID.pid_cr_w;
                                break;

                            case '7':
                                bg = PlaceID.pid_cr_k;
                                break;

                            case '8':
                                bg = PlaceID.pid_cr_g;
                                break;

                            case '\\':
                            case '/':
                                bg = PlaceID.pid_Ground;
                                break;
                            }

                            tile.BackGround = BaseTile.GetVarID((byte)bg, (byte)bgv);
                            tile.ForeGround = BaseTile.GetVarID((byte)fg, (byte)fgv);
                        }
                    }
                }
            } catch (Exception ex) {
                Logger.Write("FieldEntry.loadTemplate.1(): " + ex.Message);
            }
        }