public override void initialize() { this.Communication = Nez.Core.services.GetService <CommunicationManager>(); setDesignResolution(1280, 720, Scene.SceneResolutionPolicy.NoBorderPixelPerfect); Screen.setSize(1280, 720); var myRenderer = new ScreenSpaceRenderer(100, SCREEN_SPACE_RENDER_LAYER); myRenderer.wantsToRenderAfterPostProcessors = false; addRenderer(myRenderer); var myGUIRenderer = new RenderLayerExcludeRenderer(0, SCREEN_SPACE_RENDER_LAYER); addRenderer(myGUIRenderer); canvas = createEntity("GUI").addComponent(new UICanvas()); Texture2D LoginBackground = content.Load <Texture2D>("GUI/Login Elements/LoginBackground"); //canvas.isFullScreen = true; canvas.stage.addElement(new Image(LoginBackground)); ScrollPaneStyle myScrollStyle = new ScrollPaneStyle(); myScrollStyle.hScrollKnob = new SubtextureDrawable(Nez.Core.content.Load <Texture2D>("GUI/Scrollbar/ScrollHandle")); myScrollStyle.hScroll = new SubtextureDrawable(Nez.Core.content.Load <Texture2D>("GUI/Scrollbar/HScrollBar")); Bodies = new ScrollPane(myBodyGroup, myScrollStyle); Hair = new ScrollPane(aHairGroup, myScrollStyle); HorizontalGroup myHGroup = new HorizontalGroup(); myHGroup.setAlignment(Align.left); myHGroup.setY(70); myHGroup.setSpacing(0); VerticalGroup myCharacterDataGroup = new VerticalGroup(); myCharacterDataGroup.setSpacing(20); myCharacterDataGroup.setAlignment(Align.left); myCharacterViewerGroup = new VerticalGroup(); myCharacterViewerGroup.setY(70); HorizontalGroup mySexGroup = new HorizontalGroup(); mySexGroup.setSpacing(10); CheckBox Male = new CheckBox("Male", new CheckBoxStyle(new SubtextureDrawable(Nez.Core.content.Load <Texture2D>("GUI/Checkbox Elements/Checkbox_Unchecked")), new SubtextureDrawable(Nez.Core.content.Load <Texture2D>("GUI/Checkbox Elements/Checkbox_Checked")), Nez.Core.content.Load <BitmapFont>("Fonts/NezDefaultBMFont"), Color.White)); myDisplayedHair = new Image(); myDisplayedBody = new Image(); myImageStack.addElement(myDisplayedBody); myImageStack.addElement(myDisplayedHair); var ContainerStack = new Container(myImageStack); ContainerStack.setWidth(128); ContainerStack.setHeight(128); myCharacterViewerGroup.addElement(ContainerStack); CharacterCreatorSwitch = new Button(new ButtonStyle(new SubtextureDrawable(Core.content.Load <Texture2D>("GUI/Buttons/savebutton")), new SubtextureDrawable(Core.content.Load <Texture2D>("GUI/Buttons/savebutton")), new SubtextureDrawable(Core.content.Load <Texture2D>("GUI/Buttons/savebutton")))); CharacterCreatorSwitch.setTouchable(Touchable.Disabled); myCharacterViewerGroup.setAlignment(Align.bottom); myCharacterViewerGroup.addElement(Bodies); myCharacterViewerGroup.addElement(Hair); myCharacterViewerGroup.setPadTop(270); CheckBox Female = new CheckBox("Female", new CheckBoxStyle(new SubtextureDrawable(Nez.Core.content.Load <Texture2D>("GUI/Checkbox Elements/Checkbox_Unchecked")), new SubtextureDrawable(Nez.Core.content.Load <Texture2D>("GUI/Checkbox Elements/Checkbox_Checked")), Nez.Core.content.Load <BitmapFont>("Fonts/NezDefaultBMFont"), Color.White)); Male.onChanged += delegate(bool myResult) { if (myResult) { PlayerData.Sex = GameData.GameDataClasses.Entities.SEX.MALE; } else { PlayerData.Sex = null; } Female.programmaticChangeEvents = false; //Prevents it from firing. Female.isChecked = false; Female.programmaticChangeEvents = true; UpdateCharacterWindow(); }; Female.onChanged += delegate(bool myResult) { if (myResult) { PlayerData.Sex = GameData.GameDataClasses.Entities.SEX.FEMALE; } else { PlayerData.Sex = null; } Male.programmaticChangeEvents = false; //Prevents it from firing. Male.isChecked = false; Male.programmaticChangeEvents = true; UpdateCharacterWindow(); }; mySexGroup.addElement(Male); mySexGroup.addElement(Female); myCharacterDataGroup.addElement(mySexGroup); HorizontalGroup myRaceGroupAndDescription = new HorizontalGroup(); VerticalGroup myRaceGroup = new VerticalGroup(); List <CheckBox> myRaceChecks = new List <CheckBox>(); foreach (String A in Directory.EnumerateFiles("./Content/Races")) { String aRacename = Path.GetFileNameWithoutExtension(A); Race aLoadedRace = Nez.Core.content.Load <Race>("Races/" + aRacename); CheckBox aNewRace = new CheckBox(aRacename, new CheckBoxStyle(new SubtextureDrawable(Nez.Core.content.Load <Texture2D>("GUI/Checkbox Elements/Checkbox_Unchecked")), new SubtextureDrawable(Nez.Core.content.Load <Texture2D>("GUI/Checkbox Elements/Checkbox_Checked")), Nez.Core.content.Load <BitmapFont>("Fonts/NezDefaultBMFont"), Color.White)); myRaceChecks.Add(aNewRace); aNewRace.onChanged += delegate(bool myResult) { var Racebox = aNewRace; if (myResult) { foreach (CheckBox a in myRaceChecks) { if (Racebox != a) { a.isChecked = false; } } Race myInternalRace = aLoadedRace; SetRace(myInternalRace); UpdateCharacterWindow(); } else { SetRace(null); UpdateCharacterWindow(); } }; aNewRace.OnMouseOver += delegate(bool myResult) { if (myResult) { Race myInternalRace = aLoadedRace; myRaceDescription.setText(myInternalRace.Description); myRaceDescription.setWrap(true); } else { myRaceDescription.setText(""); } }; myRaceGroup.addElement(aNewRace); } myRaceDescription = new Label("Race Description HERE"); myRaceDescription.setWidth(Screen.width * 0.25f); myRaceDescription.setHeight(30); myRaceDescription.setWrap(true); myRaceGroup.setAlignment(Align.bottomLeft); myRaceGroupAndDescription.setSpacing(10); myRaceGroupAndDescription.setWidth(100); myRaceGroupAndDescription.addElement(myRaceGroup); myRaceGroupAndDescription.setAlignment(Align.left); Container aRaceDescriptionHolder = new Container(); aRaceDescriptionHolder.setSize(Screen.width * 0.25f, 30); aRaceDescriptionHolder.setY(0); aRaceDescriptionHolder.addElement(myRaceDescription); myRaceGroupAndDescription.addElement(aRaceDescriptionHolder); myCharacterDataGroup.addElement(myRaceGroupAndDescription); myHGroup.addElement(myCharacterDataGroup); myHGroup.addElement(myCharacterViewerGroup); //Professions GUI HorizontalGroup myHorizontalProfessions = new HorizontalGroup(); VerticalGroup myProfessionsbox = new VerticalGroup(); //Iterate professions however we're doing it myHorizontalProfessions.addElement(myProfessionsbox); VerticalGroup myProfessionsDesc = new VerticalGroup(); Label myProfessionDescription = new Label("Profession Description HERE"); myProfessionsDesc.addElement(myProfessionDescription); Label myProfessionAlert = new Label("Profession Alertbox HERE"); myProfessionsDesc.addElement(myProfessionAlert); myHorizontalProfessions.addElement(myProfessionsDesc); myCharacterDataGroup.addElement(myHorizontalProfessions); canvas.stage.addElement(myHGroup); //myHGroup.add(myInternalHGroup);*/ base.initialize(); }
public override void initialize() { this.myService = (CommunicationManager)Nez.Core.services.GetService(typeof(CommunicationManager)); // default to 1280x720 with no SceneResolutionPolicy setDesignResolution(1280, 720, Scene.SceneResolutionPolicy.ExactFit); Screen.setSize(1280, 720); var myRenderer = new ScreenSpaceRenderer(100, SCREEN_SPACE_RENDER_LAYER); myRenderer.wantsToRenderAfterPostProcessors = false; addRenderer(myRenderer); var myGUIRenderer = new RenderLayerExcludeRenderer(0, SCREEN_SPACE_RENDER_LAYER); addRenderer(myGUIRenderer); canvas = createEntity("GUI").addComponent(new UICanvas()); canvas.isFullScreen = true; // this.myCommunicationsManager = myCommunicationsManager; SpriteFont myFont = content.Load <SpriteFont>("Arial"); Texture2D TextboxBackground = content.Load <Texture2D>("GUI/Login Elements/TextField"); Texture2D PasswordHeader = content.Load <Texture2D>("GUI/Login Elements/PasswordButtonHeader"); Texture2D LoginHeader = content.Load <Texture2D>("GUI/Login Elements/LoginButtonHeader"); Texture2D LoginBackground = content.Load <Texture2D>("GUI/Login Elements/LoginBackground"); canvas.renderLayer = SCREEN_SPACE_RENDER_LAYER; TextFieldStyle myStyle = TextFieldStyle.create(Color.White, Color.White, Color.Blue, Color.Black); VerticalGroup myVerticalGroup = new VerticalGroup(); Image myLabel1 = new Image(LoginHeader); myVerticalGroup.addElement(myLabel1); myStyle.background = new SubtextureDrawable(TextboxBackground); myUsername = new TextField("", myStyle); myUsername.setHeight(TextboxBackground.Height); myUsername.setBounds(0, 0, TextboxBackground.Width, TextboxBackground.Height); myUsername.setPreferredWidth(TextboxBackground.Width); myUsername.setAlignment(Align.center); myUsername.setMaxLength(10); myVerticalGroup.addElement(myUsername); Image myLabel2 = new Image(PasswordHeader); myVerticalGroup.addElement(myLabel2); myPassword = new TextField("", myStyle); myPassword.setPasswordMode(true); myPassword.setPreferredWidth(TextboxBackground.Width); myPassword.setAlignment(Align.center); myPassword.setMaxLength(10); myVerticalGroup.addElement(myPassword); myLoginFailure = new Label("Invalid Login!"); myVerticalGroup.addElement(myLoginFailure); canvas.stage.addElement(new Image(LoginBackground, Scaling.Fit, 0)); canvas.stage.addElement(myVerticalGroup); myVerticalGroup.setPosition(Screen.width / 2, Screen.height / 2); var moonTex = content.Load <Texture2D>("GUI/Mouse/Green"); var playerEntity = createEntity("player", new Vector2(200, 200)); playerEntity.addComponent(new Sprite(moonTex)); myBUtton = new VirtualButton(); var versionLabel = new Label(InternalSettings.Version); versionLabel.setPosition(0, Screen.height - versionLabel.preferredHeight); canvas.stage.addElement(versionLabel); myLoginFailure.setIsVisible(false); myBUtton.nodes.Add(new Nez.VirtualButton.KeyboardKey(Microsoft.Xna.Framework.Input.Keys.Enter)); myService.AssignProcessor(delegate(Packet P) { myLoginFailure.setIsVisible(true); }, typeof(LoginFailedPacket)); myService.AssignProcessor(delegate(Packet P) { if (((PlayerInfoPacket)P).NewChar) { CharacterCreation myScene = SceneManager.GetScene <CharacterCreation>("CharacterCreator"); myScene.SetPlayerData(((PlayerInfoPacket)P).GetPlayerData()); MainWorldViewScene myWorldScene = SceneManager.GetScene <MainWorldViewScene>("MainWorldViewScene"); myWorldScene.SetPlayerData(((PlayerInfoPacket)P).GetPlayerData()); SceneManager.ChangeScenes("CharacterCreator"); myWorldScene.SetMapData(((PlayerInfoPacket)P).myMap); myService.AssignProcessor(null, typeof(PlayerInfoPacket)); myService.AssignProcessor(null, typeof(LoginFailedPacket)); } else { MainWorldViewScene myScene = SceneManager.GetScene <MainWorldViewScene>("MainWorldViewScene"); myScene.SetPlayerData(((PlayerInfoPacket)P).GetPlayerData()); myScene.LoadInPlayer(); myScene.SetMapData(((PlayerInfoPacket)P).myMap); SceneManager.ChangeScenes("MainWorldViewScene"); myService.AssignProcessor(null, typeof(PlayerInfoPacket)); myService.AssignProcessor(null, typeof(LoginFailedPacket)); } }, typeof(PlayerInfoPacket)); base.initialize(); }