public MaterialsBinding (UnityImporter importer) { m_importer = importer; //the max side of the code is fully asynchronous and reentrant m_materialManager = new MaterialManager(importer); m_templateManager = new TemplateManager(importer); m_textureManager = new TextureManager(importer); }
public static TextureManager getInstance() { if(instance == null){ instance = new TextureManagerInstance(); } return instance; }
TextureManager _textureManager; // 纹理控制器 #endregion Fields #region Constructors public BattleStage1(StateSystem sys, TextureManager _t, SoundManagerEx _s) { _system = sys; //状态机 _textureManager = _t; //纹理管理器 soundmanager = _s; //声音管理器 player1 = new Players.BattlePlayer(_t, 0); //实例化玩家 }
public RushBlueEffect(TextureManager _t, Vector2D Pos,float offsetangle,float w = 16,float h=16) { Position = Pos; OffsetAngle = offsetangle; Sprites = new Sprite[9]; width = w; height = h; initTextures(_t); }
public int PlayerType = 0; //人物的类型,0——player1 ,1——player2 #endregion Fields #region Constructors public BattlePlayer(TextureManager texturemanager,int type = 0) { //玩家类型(为Player1,或是为Player2) PlayerType = type; //生成一个人物数据实例 BattlePeoples p = new Battle.Players.Remilia(texturemanager); //注册人物 RegisteredRCharactors(p); }
float width = 128; //显示宽度 #endregion Fields #region Constructors /// <summary> /// 莉格露的第一段技能,横扫一圈的攻击 /// </summary> /// <param name="pos"></param> public WriggleCmp1(TextureManager texturemanager, Vector2D pos,int AttackRadius =60) { name = "WriggleCmp1"; Sprites = new List<Sprite>(); Position = new Vector2D(pos.X, pos.Y); FollowPosition = pos; AverageAngle = (360 - (JudgeEnd - JudgeBegin))/PicCount; SetAttackRaiuds(AttackRadius); initTextures(texturemanager); }
public TestSpriteClassScreen(ScreenManager screenManager, TextureManager texManager) { this._screenManager = screenManager; this._textureManager = texManager; this._renderer = new Renderer(); this._spriteList = new List<Sprite2>(); _spriteList.Add(new Face(texManager.Get("face"))); _spriteList.Add(new Face(texManager.Get("faceAlpha"))); _spriteList[1].SetColor(new Color(1, 0, 0, 1)); _spriteList[1].SetPosition(256, 256); }
public remilia_stand(TextureManager texturemanager) { //站立动画一般都为循环式的 needloop = true; //实例化动画数组 Sprites = new Sprite[8]; //设定起始索引,以及最后索引(这里举例为0-7) startIndex = 0; lastIndex = 7; name = "data_character_remilia_stand"; //调用工具函数快速部署8张纹理至Sprites BindTextureTools.BindTexures(texturemanager, name, Sprites, 0, 8); }
public ChangeOption(TextureManager _t, SoundManagerEx _s) { this.texturemanager = _t; this.soundmanager = _s; CurrentState = new SelectState(); initSprites(); _volume = new volume(Sprits); _volume.Level = soundmanager.Volume / 10; System.Diagnostics.Debug.Print(soundmanager.Volume.ToString () +"and"+ _volume.Level.ToString()); initPosition(); }
public Image(STexture sTexture = null) : base() { if (sTexture != null) { mPivotX = mPivotY = 0.0f; textureManager = TextureManager.instance; texture = sTexture; } else { throw new ArgumentError("Texture cannot be null"); } }
float width = 6; //宽 #endregion Fields #region Constructors /// <summary> /// 生成一个爆炸粒子 /// </summary> /// <param name="_t">纹理器</param> /// <param name="random">随机器</param> /// <param name="color">颜色选择(现已无用,任意填写)</param> /// <param name="position">坐标</param> public BreakPoint(TextureManager _t, Random random, int color, Vector2D position, float visibleLenth = 10) { this.random = random; int select = random.Next(4); Body = new BreakPointBody(_t, color, select); Position.X = position.X; Position.Y = position.Y; //坐标 float ag = (float)random.NextDouble() * 360; Vector2D vct = new Vector2D(0,1); vct.rotate(ag); Direction.X = vct.X; Direction.Y = vct.Y; //生成一个随机方向 visible_lenth = visibleLenth; //生成随机数据 CreteRandomData(); }
protected override void OnLoad(EventArgs e) { // Initialize GL settings GPUCapabilities.Initialize(); GLState.DepthTest = true; GLState.CullFace = true; GLState.BlendFunc(BlendingFactorSrc.DstAlpha, BlendingFactorDest.OneMinusDstAlpha); GL.ClearColor(0.25f, 0.25f, 0.25f, 1.0f); // Set up camera camera = new Camera(this); camera.Perspective(Width, Height, (float)Math.PI / 4, 1f, 1000); camera.Position = new Vector3(0, 20, 200); camera.Target = new Vector3(0, 0, -1); camera.SetAsCurrent(); // Use this camera for rendering // Set up PackageManager PackageManager.BasePath = "../../Assets/"; // Load shaders ShaderManager.LoadCollection("Shaders/collection.xml"); var shader = ShaderManager.Get("cubemappedmodel"); // Load texture textures = new TextureManager(); var texture = textures.Get("Textures/cubemap.tex", true); texture.Quality.Mipmaps = true; // Load up a mesh MeshManager meshManager = new MeshManager(); var mesh = meshManager.Get("Meshes/sphere.mesh", true); // Construct a model from shader, texture and mesh, with default material model = new Model() { Shader = shader, Texture = texture, Mesh = mesh, Material = new Material() }; // set up rendering queue renderQueue = new RenderQueue(); renderQueue.AllowInstancing = false; }
public BackGround(TextureManager _texturemanager, int level, Particle.Particles _p = null) { if (_p != null) { particles = _p; allowrunParticles = true; } this.level = level; renderer = Stage1State._renderer; this.texturemanager = _texturemanager; Texture texture = _texturemanager.Get("shade1"); background = new Sprite(); background.Texture = texture; background.SetPosition(0, 225); background.SetHeight(450); background.SetWidth(385+10); tree = new List<Tree>(); //添加一开始就有的树 for (int i = 0; i < 3; i++) { backgroundimage = new BackGroundImage(_texturemanager, renderer, "stg1bg", new Rectangle(0.01f, 0.01f, 0.48f, 0.48f), 385+10, 450); SpeedY = 0.05f; backgroundimage.SetPosition(0, 225); Tree tree1 = new Tree(texturemanager, renderer, "stg1bg", false, 200, 200); tree1.setTop(400); tree1.setPosition(16 + 30 * (float)random.NextDouble() - 15, i*200 + 60 * (float)random.NextDouble() - 30); tree.Add(tree1); tree1 = new Tree(texturemanager, renderer, "stg1bg", true, 200, 200); tree1.setTop(400); tree1.setPosition(-100 + 30 * (float)random.NextDouble() - 15, i * 200 + 100 * (float)random.NextDouble() - 50); tree.Add(tree1); tree1 = new Tree(texturemanager, renderer, "stg1bg", true, 200, 200); tree1.setTop(400); tree1.setPosition(160 + 30 * (float)random.NextDouble() - 15, i * 200 + 60 * (float)random.NextDouble() - 30); tree.Add(tree1); } }
//#define SclX(a) (GameEnv.ScreenResolution.X * ((a)/1920.0)) //#define SclY(a) (GameEnv.ScreenResolution.Y * ((a)/1080.0)) internal GraphicUserManager() { TextureManager = null; FirstFrame = new Frame(); FirstFrame.GuiManager = this; FirstFrame.ParentFrame = null; FirstFrame.Show_Frame( false ); // Init MouseOver stack imbrication tables Actual_PointedStack = new Frame[1024]; Previous_PointedStack = new Frame[1024]; Actual_FocusStack = new Frame[1024]; Previous_FocusStack = new Frame[1024]; Actual_StackSize = 0; Previous_StackSize = 0; Actual_FocusStackSize = 0; Previous_FocusStackSize = 0; DragingFrame = null; }
public BackGround(TextureManager texturemanager, int renderlevel) { _render_level = renderlevel; this._texturemanager = texturemanager; renderer = new Renderer(); BackGroundImage = new Dictionary<int, Sprite>(); BackGroundImage.Add(_MAINMENU_, new Sprite()); BackGroundImage.Add(_START_, new Sprite()); // BackGroundImage[_MAINMENU_].Texture = this._texturemanager.Get("justtest"); BackGroundImage[_MAINMENU_].Texture = this._texturemanager.Get("menu1"); BackGroundImage[_START_].Texture = this._texturemanager.Get("menu2"); //BackGroundImage[_MAINMENU_].SetPosition(0, -100); BackGroundImage[_MAINMENU_].SetPosition(0,0); BackGroundImage[_MAINMENU_].SetWidth(640); BackGroundImage[_MAINMENU_].SetHeight(640); BackGroundImage[_START_].SetWidth(1000); BackGroundImage[_START_].SetHeight(750); }
void initTextures(TextureManager texturemanager) { string head = "RushBlue_Reimu_Effect"; string middle = ""; string num; for (int i = 1; i < 10; i++) { num = i.ToString(); if (num.Length == 2) { middle = "0" + num; } else middle = "00" + num; int index = i - 1; Sprites[index] = new Sprite(); Sprites[index].Texture = texturemanager.Get(head + middle); Sprites[index].SetWidth(width); Sprites[index].SetHeight(height); Sprites[index].SetUVs(0, 0, 1, 1); } }
public ForeTable(TextureManager _t , int level) { this.level = level; texturemanager = _t; renderer = new Renderer(); tableback = new Sprite[4]; //四周的遮掩图块 Texture texture = _t.Get("foretable1");//("table1"); tableback[0] = new Sprite(); // 0 上, 1 左, 2 下, 3 右 tableback[0].Texture = texture; tableback[0].SetWidth(640); tableback[0].SetHeight(15); tableback[0].SetPosition(0, 232.5f ); //去除顶上的白线(有bug隐患) tableback[0].SetUVs(0, 0, 1, 15 / 480.0f); tableback[1] = new Sprite(); tableback[1].Texture = texture; tableback[1].SetWidth(30); tableback[1].SetHeight(450); tableback[1].SetPosition(-306,0); tableback[1].SetUVs(0, 15 / 480.0f, 28 / 640.0f, 1 - 15 / 480.0f); tableback[2] = new Sprite(); tableback[2].Texture = texture; tableback[2].SetWidth(640); tableback[2].SetHeight(15+2); tableback[2].SetPosition(0, -232.5f + 1); tableback[2].SetUVs(0, 1 - 15 / 480.0f, 1, 1); tableback[3] = new Sprite(); tableback[3].Texture = texture; tableback[3].SetWidth(225); tableback[3].SetHeight(450); tableback[3].SetPosition(209.5f -2,0); tableback[3].SetUVs(415 / 640.0f, 15 / 480.0f, 1, 1 - 15 / 480.0f); gameproperties = new GameProperties(texturemanager, new Renderer(), 150, 180); gameproperties.Scores = 34567890; }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); PackageManager.BasePath = "../../Assets/"; // Load shaders ShaderManager.LoadCollection("Shaders/collection.xml"); shader = ShaderManager.Get("texturedquad"); // Create screen-filling quad batch = new VertexBatch(); batch.StartBatch(PrimitiveType.TriangleStrip); batch.Add(new Vector3(-1, -1, 0)); // Bottom left batch.Add(new Vector3(1, -1, 0)); // Bottom right batch.Add(new Vector3(-1, 1, 0)); // Top left batch.Add(new Vector3(1, 1, 0)); // Top Right batch.EndBatch(); // Load texture textures = new TextureManager(); texture = textures.Get("Textures/concreteslabs.tex", true); }
/// <summary> /// 给BattleAnimation快速部署纹理资源 /// </summary> /// <param name="_t">纹理管理器</param> /// <param name="name">纹理的普遍头命名</param> /// <param name="Sprites">需要部署的sprite数组</param> /// <param name="startindex">第一张纹理的序号</param> /// <param name="count">部署的纹理张数</param> public static void BindTexures(TextureManager _t, string name, Sprite[] Sprites, int startindex,int count,int width = 32, int height = 32) { string head = name; string middle = ""; string num; Sprite sp; for (int i = 0; i < count; i++) { num = i.ToString(); if (num.Length == 2) { middle = "0" + num; } else middle = "00" + num; sp = new Sprite(); sp.Texture = _t.Get(head + middle); sp.SetWidth(width); sp.SetHeight(height); Sprites[i+startindex] = sp; } }
protected override void OnLoad(EventArgs e) { PackageManager.BasePath = "../../Assets/"; ShaderManager.LoadCollection("Shaders/collection.xml"); shader = ShaderManager.Get("Text"); //FontManager.LoadCollection("Fonts/fontCollection.fnt"); //font = FontManager.Get("Arial"); textures = new TextureManager(); font = new Font(); font.LoadBMFont("Fonts/OpenSans-Regular.ttf_sdf.txt"); font.Texture = textures.Get("Textures/OpenSans-Regular.ttf_sdf.tex", true); text = new GuiText(); text.Font = font; text.Text = "This is rendered with SDF technology! (now you should say ooooooooh!)"; text.HorizontalAlignment = HorizontalAlignment.Centered; }
public static void Initialize(ContentManager content, GraphicsDevice device) { Check.NullArgument (content, "content"); Check.NullArgument (device, "device"); TileEngine.TextureManager = new TextureManager(content, device, "Graphics"); TileEngine.Player = null; // Cannot assign to abstract class, removed player TileEngine.ModuleManager = new ModuleManager(); TileEngine.Configuration = null; TileEngine.WorldManager = new WorldManager(); TileEngine.NetworkManager = new NetworkClientConnection(); TileEngine.NetworkPlayerCache = new Dictionary<uint, BaseCharacter>(); TileEngine.GraphicsDevice = device; }
public Board(int newSize, Position position, Gamestate gamestate, PlayersManager playersManager, TextureManager textureManager) : base(position, gamestate) { if (IntBetweenInclusive(newSize, 2, int.MaxValue)) { Size = newSize; } else { throw new ArgumentException("Size of the board must be bigger than 1", "newSize"); } PlayersManager = playersManager; TextureManager = textureManager; Fields = new List <List <Field> >(); for (int column = 0; column < Size; column++) { Fields.Add(new List <Field>()); for (int row = 0; row < Size; row++) { Fields[column].Add(new Field(new Position(column * position.Width / Size + position.X, row * position.Height / Size + position.Y, position.Width / Size, position.Height / Size), Gamestate, PlayersManager, getTextureForField(row, column))); } } RecalculateComponentsPositions(); }
public override void LoadContent(TextureManager textureManager) { _spriteSheet = textureManager.OptionalLoadContent <Texture2D>(@"Textures/SpriteSheet"); _perecles14 = textureManager.OptionalLoadContent <SpriteFont>(@"Fonts\Perecles14"); }
public ArmorShaderData UseImage(string path) { this._uImage = TextureManager.Retrieve(path); return(this); }
internal static void LoadCursor(bool force = true) { if (!force && InputManager.s_Cursor != null && InputManager.s_Cursor.Texture != null && !InputManager.s_Cursor.Texture.IsDisposed) { return; } if (Current == null) { return; } pTexture t_cursor = TextureManager.Load(@"cursor", ConfigManager.sUseSkinCursor ? SkinSource.Skin | SkinSource.Osu : SkinSource.All); t_cursortrail = TextureManager.Load(@"cursortrail", ConfigManager.sUseSkinCursor ? SkinSource.Skin | SkinSource.Osu : SkinSource.All); if (t_cursor == null || t_cursortrail == null) { return; } InputManager.CursorExpand = Current.CursorExpand; pSprite cursor = InputManager.s_Cursor; pSprite cursor2 = InputManager.s_Cursor2; if (cursor == null) { cursor = InputManager.s_Cursor = new pSprite(null, Fields.NativeStandardScale, Origins.TopLeft, Clocks.Game, Vector2.Zero, 0.999F, true, Color.White) { Alpha = 0 }; GameBase.spriteManagerCursor.Add(cursor); cursor2 = InputManager.s_Cursor2 = new pSprite(null, Fields.NativeStandardScale, Origins.TopLeft, Clocks.Game, Vector2.Zero, 1, true, Color.White) { Alpha = 0 }; GameBase.spriteManagerCursor.Add(cursor2); } bool alreadyRotating = false; for (int i = 0; i < cursor.Transformations.Count; i++) { if (cursor.Transformations[i].Type == TransformationType.Rotation) { alreadyRotating = true; //Optimize a bit if later we will put add //more transformations to the cursor break; } } if (!Current.CursorRotate) { //Stop the rotation and reset to original position cursor.Transformations.Clear(); cursor.Rotation = 0; } else if (!alreadyRotating) { //Begin the rotation cursor.Transformations.Add(new Transformation(TransformationType.Rotation, 0, (float)Math.PI * 2, 0, 10000) { Loop = true }); } cursor.Origin = cursor2.Origin = Current.CursorCentre ? Origins.Centre : Origins.TopLeft; cursor.Scale = 1; cursor.Texture = t_cursor; cursor2.Texture = TextureManager.Load(@"cursormiddle", t_cursor.Source); InputManager.UpdateCursorSize(); }
public static Mesh CreateCubeSidedTextureOptimized(float size, Vector3 position, Vector2 textureCoordsFront, Vector2 textureCoordsBack, Vector2 textureCoordsLeft, Vector2 textureCoordsRight, Vector2 textureCoordsTop, Vector2 textureCoordsBottom, IBlock block) { Mesh mesh = new Mesh(); float s = size / 2f; List <Vector3> verts = new List <Vector3>(); List <int> tris = new List <int>(); List <Vector2> uvs = new List <Vector2>(); int triIndex = 0; float uMin, vMin, uMax, vMax; //Front if (!BlockManager.BlockExists(block.Position + Vector3.back) || (BlockManager.GetBlock(block.Position + Vector3.back) is ITransparentBlock && !(block is ITransparentBlock))) { verts.AddRange(new Vector3[] { new Vector3(-s, s, -s), // Front new Vector3(s, s, -s), // new Vector3(s, -s, -s), // new Vector3(-s, -s, -s), // }); tris.AddRange(new int[] { 0 + triIndex, 1 + triIndex, 3 + triIndex, // Front 1 + triIndex, 2 + triIndex, 3 + triIndex // }); triIndex += 4; uMin = TextureManager.GetUVMin(textureCoordsFront).x; uMax = TextureManager.GetUVMax(textureCoordsFront).x; vMin = TextureManager.GetUVMin(textureCoordsFront).y; vMax = TextureManager.GetUVMax(textureCoordsFront).y; uvs.AddRange(new List <Vector2>() { new Vector2(uMin, vMax), new Vector2(uMax, vMax), new Vector2(uMax, vMin), new Vector2(uMin, vMin) }); } //Back if (!BlockManager.BlockExists(block.Position + Vector3.forward) || (BlockManager.GetBlock(block.Position + Vector3.forward) is ITransparentBlock && !(block is ITransparentBlock))) { verts.AddRange(new Vector3[] { new Vector3(-s, s, s), // Back new Vector3(s, s, s), // new Vector3(s, -s, s), // new Vector3(-s, -s, s), // }); tris.AddRange(new int[] { 3 + triIndex, 1 + triIndex, 0 + triIndex, // Back 3 + triIndex, 2 + triIndex, 1 + triIndex // }); triIndex += 4; uMin = TextureManager.GetUVMin(textureCoordsBack).x; uMax = TextureManager.GetUVMax(textureCoordsBack).x; vMin = TextureManager.GetUVMin(textureCoordsBack).y; vMax = TextureManager.GetUVMax(textureCoordsBack).y; uvs.AddRange(new List <Vector2>() { new Vector2(uMax, vMax), new Vector2(uMin, vMax), new Vector2(uMin, vMin), new Vector2(uMax, vMin) }); } //Left if (!BlockManager.BlockExists(block.Position + Vector3.left) || (BlockManager.GetBlock(block.Position + Vector3.left) is ITransparentBlock && !(block is ITransparentBlock))) { verts.AddRange(new Vector3[] { new Vector3(-s, s, s), // Left new Vector3(-s, s, -s), // new Vector3(-s, -s, -s), // new Vector3(-s, -s, s) // }); tris.AddRange(new int[] { 0 + triIndex, 1 + triIndex, 3 + triIndex, // Left 1 + triIndex, 2 + triIndex, 3 + triIndex // }); triIndex += 4; uMin = TextureManager.GetUVMin(textureCoordsLeft).x; uMax = TextureManager.GetUVMax(textureCoordsLeft).x; vMin = TextureManager.GetUVMin(textureCoordsLeft).y; vMax = TextureManager.GetUVMax(textureCoordsLeft).y; uvs.AddRange(new List <Vector2>() { new Vector2(uMin, vMax), new Vector2(uMax, vMax), new Vector2(uMax, vMin), new Vector2(uMin, vMin) }); } //Right if (!BlockManager.BlockExists(block.Position + Vector3.right) || (BlockManager.GetBlock(block.Position + Vector3.right) is ITransparentBlock && !(block is ITransparentBlock))) { verts.AddRange(new Vector3[] { new Vector3(s, s, s), // Right new Vector3(s, s, -s), // new Vector3(s, -s, -s), // new Vector3(s, -s, s) // }); tris.AddRange(new int[] { 3 + triIndex, 1 + triIndex, 0 + triIndex, // Right 3 + triIndex, 2 + triIndex, 1 + triIndex // }); triIndex += 4; uMin = TextureManager.GetUVMin(textureCoordsRight).x; uMax = TextureManager.GetUVMax(textureCoordsRight).x; vMin = TextureManager.GetUVMin(textureCoordsRight).y; vMax = TextureManager.GetUVMax(textureCoordsRight).y; uvs.AddRange(new List <Vector2>() { new Vector2(uMax, vMax), // Right new Vector2(uMin, vMax), // new Vector2(uMin, vMin), // new Vector2(uMax, vMin), // }); } //Top if (!BlockManager.BlockExists(block.Position + Vector3.up) || (BlockManager.GetBlock(block.Position + Vector3.up) is ITransparentBlock && !(block is ITransparentBlock))) { verts.AddRange(new Vector3[] { new Vector3(-s, s, s), // Top new Vector3(-s, s, -s), // new Vector3(s, s, -s), // new Vector3(s, s, s), // }); tris.AddRange(new int[] { 3 + triIndex, 1 + triIndex, 0 + triIndex, // Top 3 + triIndex, 2 + triIndex, 1 + triIndex, // }); triIndex += 4; uMin = TextureManager.GetUVMin(textureCoordsTop).x; uMax = TextureManager.GetUVMax(textureCoordsTop).x; vMin = TextureManager.GetUVMin(textureCoordsTop).y; vMax = TextureManager.GetUVMax(textureCoordsTop).y; uvs.AddRange(new List <Vector2>() { new Vector2(uMin, vMax), // Top new Vector2(uMin, vMin), // new Vector2(uMax, vMin), // new Vector2(uMax, vMax), // }); } //Bottom if (!BlockManager.BlockExists(block.Position + Vector3.down) || (BlockManager.GetBlock(block.Position + Vector3.down) is ITransparentBlock && !(block is ITransparentBlock))) { verts.AddRange(new Vector3[] { new Vector3(-s, -s, s), // Bottom new Vector3(-s, -s, -s), // new Vector3(s, -s, -s), // new Vector3(s, -s, s) // }); tris.AddRange(new int[] { 0 + triIndex, 1 + triIndex, 3 + triIndex, // Bottom 1 + triIndex, 2 + triIndex, 3 + triIndex // }); triIndex += 4; uMin = TextureManager.GetUVMin(textureCoordsBottom).x; uMax = TextureManager.GetUVMax(textureCoordsBottom).x; vMin = TextureManager.GetUVMin(textureCoordsBottom).y; vMax = TextureManager.GetUVMax(textureCoordsBottom).y; uvs.AddRange(new List <Vector2>() { new Vector2(uMin, vMin), // Bottom new Vector2(uMin, vMax), // new Vector2(uMax, vMax), // new Vector2(uMax, vMin), // }); } for (int i = 0; i < verts.Count; i++) { verts[i] += position; } mesh.SetVertices(verts); mesh.SetTriangles(tris, 0); mesh.SetUVs(0, uvs); mesh.RecalculateNormals(); mesh.RecalculateTangents(); return(mesh); }
/// <summary> /// 绑定纹理管理器 /// </summary> /// <param name="_t">纹理管理器</param> public static void SetTexturemanager(TextureManager _t) { texturemanager = _t; }
public static void LoadContent() { AchievementCompleteUI.AchievementsTexture = TextureManager.Load("Images/UI/Achievements"); AchievementCompleteUI.AchievementsTextureBorder = TextureManager.Load("Images/UI/Achievement_Borders"); }
/// <summary> /// Performs a buffer to buffer, or buffer to texture copy. /// </summary> /// <param name="state">Current GPU state</param> /// <param name="argument">Method call argument</param> private void CopyBuffer(GpuState state, int argument) { var cbp = state.Get <CopyBufferParams>(MethodOffset.CopyBufferParams); var swizzle = state.Get <CopyBufferSwizzle>(MethodOffset.CopyBufferSwizzle); bool srcLinear = (argument & (1 << 7)) != 0; bool dstLinear = (argument & (1 << 8)) != 0; bool copy2D = (argument & (1 << 9)) != 0; int size = cbp.XCount; if (size == 0) { return; } if (copy2D) { // Buffer to texture copy. int srcBpp = swizzle.UnpackSrcComponentsCount() * swizzle.UnpackComponentSize(); int dstBpp = swizzle.UnpackDstComponentsCount() * swizzle.UnpackComponentSize(); var dst = state.Get <CopyBufferTexture>(MethodOffset.CopyBufferDstTexture); var src = state.Get <CopyBufferTexture>(MethodOffset.CopyBufferSrcTexture); var srcCalculator = new OffsetCalculator( src.Width, src.Height, cbp.SrcStride, srcLinear, src.MemoryLayout.UnpackGobBlocksInY(), src.MemoryLayout.UnpackGobBlocksInZ(), srcBpp); var dstCalculator = new OffsetCalculator( dst.Width, dst.Height, cbp.DstStride, dstLinear, dst.MemoryLayout.UnpackGobBlocksInY(), dst.MemoryLayout.UnpackGobBlocksInZ(), dstBpp); ulong srcBaseAddress = _context.MemoryManager.Translate(cbp.SrcAddress.Pack()); ulong dstBaseAddress = _context.MemoryManager.Translate(cbp.DstAddress.Pack()); (int srcBaseOffset, int srcSize) = srcCalculator.GetRectangleRange(src.RegionX, src.RegionY, cbp.XCount, cbp.YCount); (int dstBaseOffset, int dstSize) = dstCalculator.GetRectangleRange(dst.RegionX, dst.RegionY, cbp.XCount, cbp.YCount); ReadOnlySpan <byte> srcSpan = _context.PhysicalMemory.GetSpan(srcBaseAddress + (ulong)srcBaseOffset, srcSize, true); Span <byte> dstSpan = _context.PhysicalMemory.GetSpan(dstBaseAddress + (ulong)dstBaseOffset, dstSize).ToArray(); bool completeSource = IsTextureCopyComplete(cbp, src, srcLinear, srcBpp, cbp.SrcStride); bool completeDest = IsTextureCopyComplete(cbp, dst, dstLinear, dstBpp, cbp.DstStride); if (completeSource && completeDest) { Image.Texture target = TextureManager.FindTexture(dst, cbp, swizzle, dstLinear); if (target != null) { ReadOnlySpan <byte> data; if (srcLinear) { data = LayoutConverter.ConvertLinearStridedToLinear( target.Info.Width, target.Info.Height, 1, 1, cbp.SrcStride, target.Info.FormatInfo.BytesPerPixel, srcSpan); } else { data = LayoutConverter.ConvertBlockLinearToLinear( src.Width, src.Height, 1, target.Info.Levels, 1, 1, 1, srcBpp, src.MemoryLayout.UnpackGobBlocksInY(), src.MemoryLayout.UnpackGobBlocksInZ(), src.MemoryLayout.UnpackGobBlocksInX(), new SizeInfo((int)target.Size), srcSpan); } target.SetData(data); target.SignalModified(); return; } else if (srcCalculator.LayoutMatches(dstCalculator)) { srcSpan.CopyTo(dstSpan); // No layout conversion has to be performed, just copy the data entirely. _context.PhysicalMemory.Write(dstBaseAddress + (ulong)dstBaseOffset, dstSpan); return; } } unsafe bool Convert <T>(Span <byte> dstSpan, ReadOnlySpan <byte> srcSpan) where T : unmanaged { fixed(byte *dstPtr = dstSpan, srcPtr = srcSpan) { byte *dstBase = dstPtr - dstBaseOffset; // Layout offset is relative to the base, so we need to subtract the span's offset. byte *srcBase = srcPtr - srcBaseOffset; for (int y = 0; y < cbp.YCount; y++) { srcCalculator.SetY(src.RegionY + y); dstCalculator.SetY(dst.RegionY + y); for (int x = 0; x < cbp.XCount; x++) { int srcOffset = srcCalculator.GetOffset(src.RegionX + x); int dstOffset = dstCalculator.GetOffset(dst.RegionX + x); *(T *)(dstBase + dstOffset) = *(T *)(srcBase + srcOffset); } } } return(true); } bool _ = srcBpp switch { 1 => Convert <byte>(dstSpan, srcSpan), 2 => Convert <ushort>(dstSpan, srcSpan), 4 => Convert <uint>(dstSpan, srcSpan), 8 => Convert <ulong>(dstSpan, srcSpan), 12 => Convert <Bpp12Pixel>(dstSpan, srcSpan), 16 => Convert <Vector128 <byte> >(dstSpan, srcSpan), _ => throw new NotSupportedException($"Unable to copy ${srcBpp} bpp pixel format.") }; _context.PhysicalMemory.Write(dstBaseAddress + (ulong)dstBaseOffset, dstSpan); } else { // Buffer to buffer copy. BufferManager.CopyBuffer(cbp.SrcAddress, cbp.DstAddress, (uint)size); } }
//~~~~~~~~~~~~~~~~~~~~// // Static Functions // //~~~~~~~~~~~~~~~~~~~~// private static void InitializeRecipeBooks() { //~~~~~~~~~~~~~~~~~~~// // Workbench Recipes // //~~~~~~~~~~~~~~~~~~~// #region CraftingRecipeBook WorkbenchRecipes = new CraftingRecipeBook("Workbench"); WorkbenchRecipes.addInCraftingTab("Default", new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Default Tab", new Vector2(100 + 48, 100 + (24 * 4)), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "MenuTabHorizontal"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f), true); WorkbenchRecipes.addInCraftingTab("Furniture", new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Furniture Tab", new Vector2(100 + 48, 100 + (24 * 4) * 2), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "MenuTabHorizontal"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f), false); WorkbenchRecipes.addCraftingRecipe("Anvil", new UnlockableCraftingRecipe("Default", new Recipe(new List <CraftingRecipeComponent>() { //Inputs here new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("SteelIngot"), 20) }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("Anvil"), 1)), true)); WorkbenchRecipes.addCraftingRecipe("Pickaxe", new UnlockableCraftingRecipe("Default", new Recipe(new List <CraftingRecipeComponent>() { new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Stone, 20), 20), new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Wood, 10), 10) }, new CraftingRecipeComponent(new StardewValley.Tools.Pickaxe() { UpgradeLevel = 0 }, 1)), true)); WorkbenchRecipes.addCraftingRecipe("Axe", new UnlockableCraftingRecipe("Default", new Recipe(new List <CraftingRecipeComponent>() { new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Stone, 20), 20), new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Wood, 10), 10) }, new CraftingRecipeComponent(new StardewValley.Tools.Axe() { UpgradeLevel = 0 }, 1)), true)); WorkbenchRecipes.addCraftingRecipe("Hoe", new UnlockableCraftingRecipe("Default", new Recipe(new List <CraftingRecipeComponent>() { new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Stone, 20), 20), new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Wood, 10), 10) }, new CraftingRecipeComponent(new StardewValley.Tools.Hoe() { UpgradeLevel = 0 }, 1)), true)); WorkbenchRecipes.addCraftingRecipe("Watering Can", new UnlockableCraftingRecipe("Default", new Recipe(new List <CraftingRecipeComponent>() { new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Stone, 20), 20), }, new CraftingRecipeComponent(new StardewValley.Tools.WateringCan() { UpgradeLevel = 0 }, 1)), true)); WorkbenchRecipes.addCraftingRecipe("Copper Wire", new UnlockableCraftingRecipe("Default", new Recipe(new List <CraftingRecipeComponent>() { new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.CopperBar, 1), 1), }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("CopperWire"), 2), null, 0), true)); /* * WorkbenchRecipes.addCraftingRecipe("Alloy Furnace", new UnlockableCraftingRecipe("Default", new Recipe(new List<CraftingRecipeComponent>() * { * new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Clay,20),10), * new CraftingRecipeComponent(ModCore.ObjectManager.resources.getResource("Sand"), 10) * }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("AlloyFurnace"), 1), null, 0), true)); * WorkbenchRecipes.addCraftingRecipe("Sand Box", new UnlockableCraftingRecipe("Default", new Recipe(new List<CraftingRecipeComponent>() * { * new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Wood,100),100), * new CraftingRecipeComponent(ModCore.ObjectManager.resources.getResource("Sand"), 25) * }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("SandBox"), 1), null, 0), true)); */ WorkbenchRecipes.addCraftingRecipe("Battery Bin", new UnlockableCraftingRecipe("Default", new Recipe(new List <CraftingRecipeComponent>() { new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Wood, 100), 100), new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("ElectrumIngot"), 10) }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("BatteryBin"), 1), null, 0), true)); WorkbenchRecipes.addCraftingRecipe("Capacitor", new UnlockableCraftingRecipe("Default", new Recipe(new List <CraftingRecipeComponent>() { new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Wood, 50), 50), new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.CopperBar, 10), 10) }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("Capacitor"), 1), null, 0), true)); WorkbenchRecipes.addCraftingRecipe("Charging Station", new UnlockableCraftingRecipe("Default", new Recipe(new List <CraftingRecipeComponent>() { new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Wood, 100), 100), new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.IronBar, 10), 10), new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("CopperWire"), 20), new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("Capacitor"), 1) }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("ChargingStation"), 1), null, 0), true)); WorkbenchRecipes.addCraftingRecipe("Oak Chair", new UnlockableCraftingRecipe("Furniture", new Recipe(new List <CraftingRecipeComponent>(), new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("Oak Chair"), 1), new StatCost(0, 0, 100, 0), 0), true)); if (CraftingRecipesByGroup.ContainsKey(WorkbenchRecipes.craftingGroup)) { foreach (KeyValuePair <string, AnimatedButton> pair in WorkbenchRecipes.craftingMenuTabs) { if (CraftingRecipesByGroup[WorkbenchRecipes.craftingGroup].craftingMenuTabs.ContainsKey(pair.Key)) { } else { CraftingRecipesByGroup[WorkbenchRecipes.craftingGroup].craftingMenuTabs.Add(pair.Key, pair.Value); } } foreach (KeyValuePair <string, UnlockableCraftingRecipe> recipe in WorkbenchRecipes.craftingRecipes) { if (CraftingRecipesByGroup[WorkbenchRecipes.craftingGroup].craftingRecipes.ContainsKey(recipe.Key)) { } else { CraftingRecipesByGroup[WorkbenchRecipes.craftingGroup].craftingRecipes.Add(recipe.Key, recipe.Value); //Add in new recipes automatically without having to delete the old crafting recipe book. } } } else { CraftingRecipesByGroup.Add("Workbench", WorkbenchRecipes); } #endregion //~~~~~~~~~~~~~~~~~~// // Anvil Recipes // //~~~~~~~~~~~~~~~~~~// CraftingRecipeBook AnvilRecipes = new CraftingRecipeBook("Anvil"); AnvilRecipes.addInCraftingTab("Default", new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Default Tab", new Vector2(100 + 48, 100 + (24 * 4)), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "MenuTabHorizontal"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f), true); //~~~~~~~~~~~~~~~~~~~~~~~// //Alternate Vanilla Tools// //~~~~~~~~~~~~~~~~~~~~~~~// #region //Watering Cans AnvilRecipes.addCraftingRecipe("Bronze Watering Can", new UnlockableCraftingRecipe("Default", new Recipe(new List <CraftingRecipeComponent>() { new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("BronzeIngot", 15), 15), new CraftingRecipeComponent(new StardewValley.Tools.WateringCan() { UpgradeLevel = 0 }, 1) }, new CraftingRecipeComponent(ModCore.ObjectManager.GetTool("BronzeWateringCan"), 1)), true)); AnvilRecipes.addCraftingRecipe("Hardened Watering Can", new UnlockableCraftingRecipe("Default", new Recipe(new List <CraftingRecipeComponent>() { new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("SteelIngot", 10), 10), new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("LeadIngot", 5), 5), new CraftingRecipeComponent(ModCore.ObjectManager.GetTool("BronzeWateringCan"), 1) }, new CraftingRecipeComponent(ModCore.ObjectManager.GetTool("HardenedWateringCan"), 1)), true)); AnvilRecipes.addCraftingRecipe("Titanium Watering Can", new UnlockableCraftingRecipe("Default", new Recipe(new List <CraftingRecipeComponent>() { new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("TitaniumIngot", 15), 15), new CraftingRecipeComponent(ModCore.ObjectManager.GetTool("HardenedWateringCan"), 1) }, new CraftingRecipeComponent(ModCore.ObjectManager.GetTool("TitaniumWateringCan"), 1)), true)); //Pickaxes AnvilRecipes.addCraftingRecipe("Bronze Pickaxe", new UnlockableCraftingRecipe("Default", new Recipe(new List <CraftingRecipeComponent>() { new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("BronzeIngot", 15), 15), new CraftingRecipeComponent(new StardewValley.Tools.Pickaxe() { UpgradeLevel = 0 }, 1) }, new CraftingRecipeComponent(ModCore.ObjectManager.GetTool("BronzePickaxe"), 1)), true)); AnvilRecipes.addCraftingRecipe("Hardened Pickaxe", new UnlockableCraftingRecipe("Default", new Recipe(new List <CraftingRecipeComponent>() { new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("SteelIngot", 10), 10), new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("LeadIngot", 5), 5), new CraftingRecipeComponent(ModCore.ObjectManager.GetTool("BronzePickaxe"), 1) }, new CraftingRecipeComponent(ModCore.ObjectManager.GetTool("HardenedPickaxe"), 1)), true)); AnvilRecipes.addCraftingRecipe("Titanium Pickaxe", new UnlockableCraftingRecipe("Default", new Recipe(new List <CraftingRecipeComponent>() { new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("TitaniumIngot", 15), 15), new CraftingRecipeComponent(ModCore.ObjectManager.GetTool("HardenedPickaxe"), 1) }, new CraftingRecipeComponent(ModCore.ObjectManager.GetTool("TitaniumPickaxe"), 1)), true)); //Axes AnvilRecipes.addCraftingRecipe("Bronze Axe", new UnlockableCraftingRecipe("Default", new Recipe(new List <CraftingRecipeComponent>() { new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("BronzeIngot", 15), 15), new CraftingRecipeComponent(new StardewValley.Tools.Axe() { UpgradeLevel = 0 }, 1) }, new CraftingRecipeComponent(ModCore.ObjectManager.GetTool("BronzeAxe"), 1)), true)); AnvilRecipes.addCraftingRecipe("Hardened Axe", new UnlockableCraftingRecipe("Default", new Recipe(new List <CraftingRecipeComponent>() { new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("SteelIngot", 10), 10), new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("LeadIngot", 5), 5), new CraftingRecipeComponent(ModCore.ObjectManager.GetTool("BronzeAxe"), 1) }, new CraftingRecipeComponent(ModCore.ObjectManager.GetTool("HardenedAxe"), 1)), true)); AnvilRecipes.addCraftingRecipe("Titanium Axe", new UnlockableCraftingRecipe("Default", new Recipe(new List <CraftingRecipeComponent>() { new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("TitaniumIngot", 15), 15), new CraftingRecipeComponent(ModCore.ObjectManager.GetTool("HardenedAxe"), 1) }, new CraftingRecipeComponent(ModCore.ObjectManager.GetTool("TitaniumAxe"), 1)), true)); ///Plows AnvilRecipes.addCraftingRecipe("Bronze Hoe", new UnlockableCraftingRecipe("Default", new Recipe(new List <CraftingRecipeComponent>() { new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("BronzeIngot", 15), 15), new CraftingRecipeComponent(new StardewValley.Tools.Hoe() { UpgradeLevel = 0 }, 1) }, new CraftingRecipeComponent(ModCore.ObjectManager.GetTool("BronzeHoe"), 1)), true)); AnvilRecipes.addCraftingRecipe("Hardened Hoe", new UnlockableCraftingRecipe("Default", new Recipe(new List <CraftingRecipeComponent>() { new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("SteelIngot", 10), 10), new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("LeadIngot", 5), 5), new CraftingRecipeComponent(ModCore.ObjectManager.GetTool("BronzeHoe"), 1) }, new CraftingRecipeComponent(ModCore.ObjectManager.GetTool("HardenedHoe"), 1)), true)); AnvilRecipes.addCraftingRecipe("Titanium Hoe", new UnlockableCraftingRecipe("Default", new Recipe(new List <CraftingRecipeComponent>() { new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("TitaniumIngot", 15), 15), new CraftingRecipeComponent(ModCore.ObjectManager.GetTool("HardenedHoe"), 1) }, new CraftingRecipeComponent(ModCore.ObjectManager.GetTool("TitaniumHoe"), 1)), true)); #endregion AnvilRecipes.addCraftingRecipe("Trash Can", new UnlockableCraftingRecipe("Default", new Recipe(new List <CraftingRecipeComponent>() { new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.IronBar, 5), 5) }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("TrashCan"), 1)), true)); AnvilRecipes.addCraftingRecipe("Iron Pipe", new UnlockableCraftingRecipe("Default", new Recipe(new List <CraftingRecipeComponent>() { new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.IronBar, 2), 2) }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("IronPipe"), 1)), true)); /* * AnvilRecipes.addCraftingRecipe("Solar Panel", new UnlockableCraftingRecipe("Default", new Recipe(new List<CraftingRecipeComponent>() * { * new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.IronBar,10),10), * new CraftingRecipeComponent(ModCore.ObjectManager.resources.getResource("Glass"),4), * }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("SolarPanelTier1"), 1)), true)); */ /* * AnvilRecipes.addCraftingRecipe("Solar Array", new UnlockableCraftingRecipe("Default", new Recipe(new List<CraftingRecipeComponent>() * { * new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.IronBar,45),45), * new CraftingRecipeComponent(ModCore.ObjectManager.resources.getResource("Glass"),20), * }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("SolarArrayTier1"), 1)), true)); */ /* * ///Alt solar array crafting recipe. * AnvilRecipes.addCraftingRecipe("Solar Array Alt. Recipe", new UnlockableCraftingRecipe("Default", new Recipe(new List<CraftingRecipeComponent>() * { * new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.IronBar,5),5), * new CraftingRecipeComponent(ModCore.ObjectManager.resources.getResource("Glass"),4), * new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("SolarPanelTier1"), 4) * }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("SolarArrayTier1"), 1)), true)); * * AnvilRecipes.addCraftingRecipe("LightHouse", new UnlockableCraftingRecipe("Default", new Recipe(new List<CraftingRecipeComponent>() * { * new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.IronBar,5),5), * new CraftingRecipeComponent(ModCore.ObjectManager.resources.getResource("Glass"),5), * new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Wood,10), 10) * }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("Lighthouse"), 1)), true)); */ AnvilRecipes.addCraftingRecipe("Grinder", new UnlockableCraftingRecipe("Default", new Recipe(new List <CraftingRecipeComponent>() { new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.IronBar, 10), 10), new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("SteelIngot"), 30), new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.CopperBar, 10), 10), new CraftingRecipeComponent(new StardewValley.Objects.Chest(true), 1) }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("Grinder"), 1)), true)); AnvilRecipes.addCraftingRecipe("Mining Drill V1", new UnlockableCraftingRecipe("Default", new Recipe(new List <CraftingRecipeComponent>() { new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("SteelIngot", 10), 10), new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("BrassIngot", 10), 10), new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.BatteryPack, 1), 1) }, new CraftingRecipeComponent(ModCore.ObjectManager.GetTool("MiningDrillV1"), 1)), true)); AnvilRecipes.addCraftingRecipe("Chainsaw V1", new UnlockableCraftingRecipe("Default", new Recipe(new List <CraftingRecipeComponent>() { new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("SteelIngot", 10), 10), new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("BronzeIngot", 10), 10), new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.BatteryPack, 1), 1) }, new CraftingRecipeComponent(ModCore.ObjectManager.GetTool("ChainsawV1"), 1)), true)); AnvilRecipes.addCraftingRecipe("Water Pump V1", new UnlockableCraftingRecipe("Default", new Recipe(new List <CraftingRecipeComponent>() { new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.IronBar, 15), 15) }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("WaterPumpV1"), 1)), true)); AnvilRecipes.addCraftingRecipe("Steam Boiler V1", new UnlockableCraftingRecipe("Default", new Recipe(new List <CraftingRecipeComponent>() { new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.IronBar, 25), 25), new CraftingRecipeComponent(new StardewValley.Objects.Chest(true), 1) }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("SteamBoilerV1"), 1)), true)); if (CraftingRecipesByGroup.ContainsKey(AnvilRecipes.craftingGroup)) { foreach (KeyValuePair <string, AnimatedButton> pair in AnvilRecipes.craftingMenuTabs) { if (CraftingRecipesByGroup[AnvilRecipes.craftingGroup].craftingMenuTabs.ContainsKey(pair.Key)) { } else { CraftingRecipesByGroup[AnvilRecipes.craftingGroup].craftingMenuTabs.Add(pair.Key, pair.Value); } } foreach (KeyValuePair <string, UnlockableCraftingRecipe> recipe in AnvilRecipes.craftingRecipes) { if (CraftingRecipesByGroup[AnvilRecipes.craftingGroup].craftingRecipes.ContainsKey(recipe.Key)) { } else { CraftingRecipesByGroup[AnvilRecipes.craftingGroup].craftingRecipes.Add(recipe.Key, recipe.Value); //Add in new recipes automatically without having to delete the old crafting recipe book. } } } else { CraftingRecipesByGroup.Add("Anvil", AnvilRecipes); } //~~~~~~~~~~~~~~~~~~~~~~~// // Alloy Furnace Recipes // //~~~~~~~~~~~~~~~~~~~~~~~// CraftingRecipeBook AlloyFurnaceRecipes = new CraftingRecipeBook("AlloyFurnace"); AlloyFurnaceRecipes.addInCraftingTab("Default", new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Default Tab", new Vector2(100 + 48, 100 + (24 * 4)), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "MenuTabHorizontal"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f), true); AlloyFurnaceRecipes.addCraftingRecipe("BrassIngot", new UnlockableCraftingRecipe("Default", new Recipe(new List <CraftingRecipeComponent>() { new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.CopperBar, 1), 1), new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("AluminumIngot"), 1), new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Coal, 5), 1) }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("BrassIngot"), 1), null, TimeUtilities.GetMinutesFromTime(0, 3, 0)), true)); AlloyFurnaceRecipes.addCraftingRecipe("BronzeIngot", new UnlockableCraftingRecipe("Default", new Recipe(new List <CraftingRecipeComponent>() { new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.CopperBar, 1), 1), new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("TinIngot"), 1), new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Coal, 5), 1) }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("BronzeIngot"), 1), null, TimeUtilities.GetMinutesFromTime(0, 4, 0)), true)); AlloyFurnaceRecipes.addCraftingRecipe("SteelIngot", new UnlockableCraftingRecipe("Default", new Recipe(new List <CraftingRecipeComponent>() { new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.IronBar, 1), 1), new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Coal, 5), 1) }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("SteelIngot"), 1), null, TimeUtilities.GetMinutesFromTime(0, 6, 0)), true)); AlloyFurnaceRecipes.addCraftingRecipe("ElectrumIngot", new UnlockableCraftingRecipe("Default", new Recipe(new List <CraftingRecipeComponent>() { new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.GoldBar, 1), 1), new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("SilverIngot"), 1), new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Coal, 5), 1) }, new CraftingRecipeComponent(ModCore.ObjectManager.GetItem("ElectrumIngot"), 1), null, TimeUtilities.GetMinutesFromTime(0, 4, 0)), true)); if (CraftingRecipesByGroup.ContainsKey(AlloyFurnaceRecipes.craftingGroup)) { foreach (KeyValuePair <string, UnlockableCraftingRecipe> recipe in AlloyFurnaceRecipes.craftingRecipes) { if (CraftingRecipesByGroup[AlloyFurnaceRecipes.craftingGroup].craftingRecipes.ContainsKey(recipe.Key)) { } else { CraftingRecipesByGroup[AlloyFurnaceRecipes.craftingGroup].craftingRecipes.Add(recipe.Key, recipe.Value); //Add in new recipes automatically without having to delete the old crafting recipe book. } } } else { CraftingRecipesByGroup.Add("AlloyFurnace", AlloyFurnaceRecipes); } }
/// <summary> /// Dispatches compute work. /// </summary> /// <param name="state">Current GPU state</param> /// <param name="argument">Method call argument</param> public void Dispatch(GpuState state, int argument) { uint qmdAddress = (uint)state.Get <int>(MethodOffset.DispatchParamsAddress); var qmd = _context.MemoryManager.Read <ComputeQmd>((ulong)qmdAddress << 8); GpuVa shaderBaseAddress = state.Get <GpuVa>(MethodOffset.ShaderBaseAddress); ulong shaderGpuVa = shaderBaseAddress.Pack() + (uint)qmd.ProgramOffset; int localMemorySize = qmd.ShaderLocalMemoryLowSize + qmd.ShaderLocalMemoryHighSize; int sharedMemorySize = Math.Min(qmd.SharedMemorySize, _context.Capabilities.MaximumComputeSharedMemorySize); uint sbEnableMask = 0; uint ubEnableMask = 0; for (int index = 0; index < Constants.TotalCpUniformBuffers; index++) { if (!qmd.ConstantBufferValid(index)) { continue; } ubEnableMask |= 1u << index; ulong gpuVa = (uint)qmd.ConstantBufferAddrLower(index) | (ulong)qmd.ConstantBufferAddrUpper(index) << 32; ulong size = (ulong)qmd.ConstantBufferSize(index); BufferManager.SetComputeUniformBuffer(index, gpuVa, size); } ShaderBundle cs = ShaderCache.GetComputeShader( state, shaderGpuVa, qmd.CtaThreadDimension0, qmd.CtaThreadDimension1, qmd.CtaThreadDimension2, localMemorySize, sharedMemorySize); _context.Renderer.Pipeline.SetProgram(cs.HostProgram); var samplerPool = state.Get <PoolState>(MethodOffset.SamplerPoolState); TextureManager.SetComputeSamplerPool(samplerPool.Address.Pack(), samplerPool.MaximumId, qmd.SamplerIndex); var texturePool = state.Get <PoolState>(MethodOffset.TexturePoolState); TextureManager.SetComputeTexturePool(texturePool.Address.Pack(), texturePool.MaximumId); TextureManager.SetComputeTextureBufferIndex(state.Get <int>(MethodOffset.TextureBufferIndex)); ShaderProgramInfo info = cs.Shaders[0].Program.Info; for (int index = 0; index < info.CBuffers.Count; index++) { BufferDescriptor cb = info.CBuffers[index]; // NVN uses the "hardware" constant buffer for anything that is less than 8, // and those are already bound above. // Anything greater than or equal to 8 uses the emulated constant buffers. // They are emulated using global memory loads. if (cb.Slot < 8) { continue; } ubEnableMask |= 1u << cb.Slot; ulong cbDescAddress = BufferManager.GetComputeUniformBufferAddress(0); int cbDescOffset = 0x260 + (cb.Slot - 8) * 0x10; cbDescAddress += (ulong)cbDescOffset; SbDescriptor cbDescriptor = _context.PhysicalMemory.Read <SbDescriptor>(cbDescAddress); BufferManager.SetComputeUniformBuffer(cb.Slot, cbDescriptor.PackAddress(), (uint)cbDescriptor.Size); } for (int index = 0; index < info.SBuffers.Count; index++) { BufferDescriptor sb = info.SBuffers[index]; sbEnableMask |= 1u << sb.Slot; ulong sbDescAddress = BufferManager.GetComputeUniformBufferAddress(0); int sbDescOffset = 0x310 + sb.Slot * 0x10; sbDescAddress += (ulong)sbDescOffset; SbDescriptor sbDescriptor = _context.PhysicalMemory.Read <SbDescriptor>(sbDescAddress); BufferManager.SetComputeStorageBuffer(sb.Slot, sbDescriptor.PackAddress(), (uint)sbDescriptor.Size); } ubEnableMask = 0; for (int index = 0; index < info.CBuffers.Count; index++) { ubEnableMask |= 1u << info.CBuffers[index].Slot; } BufferManager.SetComputeStorageBufferEnableMask(sbEnableMask); BufferManager.SetComputeUniformBufferEnableMask(ubEnableMask); var textureBindings = new TextureBindingInfo[info.Textures.Count]; for (int index = 0; index < info.Textures.Count; index++) { var descriptor = info.Textures[index]; Target target = GetTarget(descriptor.Type); if (descriptor.IsBindless) { textureBindings[index] = new TextureBindingInfo(target, descriptor.CbufOffset, descriptor.CbufSlot, descriptor.Flags); } else { textureBindings[index] = new TextureBindingInfo(target, descriptor.HandleIndex, descriptor.Flags); } } TextureManager.SetComputeTextures(textureBindings); var imageBindings = new TextureBindingInfo[info.Images.Count]; for (int index = 0; index < info.Images.Count; index++) { var descriptor = info.Images[index]; Target target = GetTarget(descriptor.Type); imageBindings[index] = new TextureBindingInfo(target, descriptor.HandleIndex, descriptor.Flags); } TextureManager.SetComputeImages(imageBindings); BufferManager.CommitComputeBindings(); TextureManager.CommitComputeBindings(); _context.Renderer.Pipeline.DispatchCompute( qmd.CtaRasterWidth, qmd.CtaRasterHeight, qmd.CtaRasterDepth); _forceShaderUpdate = true; }
public UIVirtualKeyboard(string labelText, string startingText, UIVirtualKeyboard.KeyboardSubmitEvent submitAction, Action cancelAction, int inputMode = 0, bool allowEmpty = false) { this._keyboardContext = inputMode; this._allowEmpty = allowEmpty; UIVirtualKeyboard.OffsetDown = 0; this._lastOffsetDown = 0; this._edittingSign = this._keyboardContext == 1; this._edittingChest = this._keyboardContext == 2; UIVirtualKeyboard._currentInstance = this; this._submitAction = submitAction; this._cancelAction = cancelAction; this._textureShift = TextureManager.Load("Images/UI/VK_Shift"); this._textureBackspace = TextureManager.Load("Images/UI/VK_Backspace"); this.Top.Pixels = (float)this._lastOffsetDown; float num1 = (float)(-5000 * this._edittingSign.ToInt()); float maxValue = (float)byte.MaxValue; float num2 = 0.0f; float num3 = 516f; UIElement element = new UIElement(); element.Width.Pixels = (float)((double)num3 + 8.0 + 16.0); element.Top.Precent = num2; element.Top.Pixels = maxValue; element.Height.Pixels = 266f; element.HAlign = 0.5f; element.SetPadding(0.0f); this.outerLayer1 = element; UIElement uiElement = new UIElement(); uiElement.Width.Pixels = (float)((double)num3 + 8.0 + 16.0); uiElement.Top.Precent = num2; uiElement.Top.Pixels = maxValue; uiElement.Height.Pixels = 266f; uiElement.HAlign = 0.5f; uiElement.SetPadding(0.0f); this.outerLayer2 = uiElement; UIPanel mainPanel = new UIPanel(); mainPanel.Width.Precent = 1f; mainPanel.Height.Pixels = 225f; mainPanel.BackgroundColor = new Color(23, 33, 69) * 0.7f; element.Append((UIElement)mainPanel); float num4 = -79f; this._textBox = new UITextBox("", 0.78f, true); this._textBox.BackgroundColor = Color.Transparent; this._textBox.BorderColor = Color.Transparent; this._textBox.HAlign = 0.5f; this._textBox.Width.Pixels = num3; this._textBox.Top.Pixels = (float)((double)num4 + (double)maxValue - 10.0) + num1; this._textBox.Top.Precent = num2; this._textBox.Height.Pixels = 37f; this.Append((UIElement)this._textBox); for (int x = 0; x < 10; ++x) { for (int y = 0; y < 4; ++y) { UITextPanel <object> keyboardButton = this.CreateKeyboardButton((object)"1234567890qwertyuiopasdfghjkl'zxcvbnm,.?"[y * 10 + x].ToString(), x, y, 1, true); keyboardButton.OnClick += new UIElement.MouseEvent(this.TypeText); mainPanel.Append((UIElement)keyboardButton); } } this._shiftButton = this.CreateKeyboardButton((object)"", 0, 4, 1, false); this._shiftButton.PaddingLeft = 0.0f; this._shiftButton.PaddingRight = 0.0f; this._shiftButton.PaddingBottom = this._shiftButton.PaddingTop = 0.0f; this._shiftButton.BackgroundColor = new Color(63, 82, 151) * 0.7f; this._shiftButton.BorderColor = this._internalBorderColor * 0.7f; this._shiftButton.OnMouseOver += (UIElement.MouseEvent)((evt, listeningElement) => { this._shiftButton.BorderColor = this._internalBorderColorSelected; if (this._keyState == UIVirtualKeyboard.KeyState.Shift) { return; } this._shiftButton.BackgroundColor = new Color(73, 94, 171); }); this._shiftButton.OnMouseOut += (UIElement.MouseEvent)((evt, listeningElement) => { this._shiftButton.BorderColor = this._internalBorderColor * 0.7f; if (this._keyState == UIVirtualKeyboard.KeyState.Shift) { return; } this._shiftButton.BackgroundColor = new Color(63, 82, 151) * 0.7f; }); this._shiftButton.OnClick += (UIElement.MouseEvent)((evt, listeningElement) => { Main.PlaySound(12, -1, -1, 1, 1f, 0.0f); this.SetKeyState(this._keyState == UIVirtualKeyboard.KeyState.Shift ? UIVirtualKeyboard.KeyState.Default : UIVirtualKeyboard.KeyState.Shift); }); UIImage uiImage1 = new UIImage(this._textureShift); uiImage1.HAlign = 0.5f; uiImage1.VAlign = 0.5f; uiImage1.ImageScale = 0.85f; this._shiftButton.Append((UIElement)uiImage1); mainPanel.Append((UIElement)this._shiftButton); this._symbolButton = this.CreateKeyboardButton((object)"@%", 1, 4, 1, false); this._symbolButton.PaddingLeft = 0.0f; this._symbolButton.PaddingRight = 0.0f; this._symbolButton.BackgroundColor = new Color(63, 82, 151) * 0.7f; this._symbolButton.BorderColor = this._internalBorderColor * 0.7f; this._symbolButton.OnMouseOver += (UIElement.MouseEvent)((evt, listeningElement) => { this._symbolButton.BorderColor = this._internalBorderColorSelected; if (this._keyState == UIVirtualKeyboard.KeyState.Symbol) { return; } this._symbolButton.BackgroundColor = new Color(73, 94, 171); }); this._symbolButton.OnMouseOut += (UIElement.MouseEvent)((evt, listeningElement) => { this._symbolButton.BorderColor = this._internalBorderColor * 0.7f; if (this._keyState == UIVirtualKeyboard.KeyState.Symbol) { return; } this._symbolButton.BackgroundColor = new Color(63, 82, 151) * 0.7f; }); this._symbolButton.OnClick += (UIElement.MouseEvent)((evt, listeningElement) => { Main.PlaySound(12, -1, -1, 1, 1f, 0.0f); this.SetKeyState(this._keyState == UIVirtualKeyboard.KeyState.Symbol ? UIVirtualKeyboard.KeyState.Default : UIVirtualKeyboard.KeyState.Symbol); }); mainPanel.Append((UIElement)this._symbolButton); this.BuildSpaceBarArea(mainPanel); this._submitButton = new UITextPanel <LocalizedText>(this._edittingSign || this._edittingChest ? Language.GetText("UI.Save") : Language.GetText("UI.Submit"), 0.4f, true); this._submitButton.Height.Pixels = 37f; this._submitButton.Width.Precent = 0.4f; this._submitButton.HAlign = 1f; this._submitButton.VAlign = 1f; this._submitButton.PaddingLeft = 0.0f; this._submitButton.PaddingRight = 0.0f; this.ValidateText(); this._submitButton.OnMouseOver += (UIElement.MouseEvent)((evt, listeningElement) => this.ValidateText()); this._submitButton.OnMouseOut += (UIElement.MouseEvent)((evt, listeningElement) => this.ValidateText()); this._submitButton.OnClick += (UIElement.MouseEvent)((evt, listeningElement) => { string text = this.Text.Trim(); if (text.Length <= 0 && !this._edittingSign && (!this._edittingChest && !this._allowEmpty)) { return; } Main.PlaySound(10, -1, -1, 1, 1f, 0.0f); this._submitAction(text); }); element.Append((UIElement)this._submitButton); this._cancelButton = new UITextPanel <LocalizedText>(Language.GetText("UI.Cancel"), 0.4f, true); this.StyleKey <LocalizedText>(this._cancelButton, true); this._cancelButton.Height.Pixels = 37f; this._cancelButton.Width.Precent = 0.4f; this._cancelButton.VAlign = 1f; this._cancelButton.OnClick += (UIElement.MouseEvent)((evt, listeningElement) => { Main.PlaySound(11, -1, -1, 1, 1f, 0.0f); this._cancelAction(); }); element.Append((UIElement)this._cancelButton); this._submitButton2 = new UITextPanel <LocalizedText>(this._edittingSign || this._edittingChest ? Language.GetText("UI.Save") : Language.GetText("UI.Submit"), 0.72f, true); this._submitButton2.TextColor = Color.Silver; this._submitButton2.DrawPanel = false; this._submitButton2.Height.Pixels = 60f; this._submitButton2.Width.Precent = 0.4f; this._submitButton2.HAlign = 0.5f; this._submitButton2.VAlign = 0.0f; this._submitButton2.OnMouseOver += (UIElement.MouseEvent)((a, b) => { ((UITextPanel <LocalizedText>)b).TextScale = 0.85f; ((UITextPanel <LocalizedText>)b).TextColor = Color.White; }); this._submitButton2.OnMouseOut += (UIElement.MouseEvent)((a, b) => { ((UITextPanel <LocalizedText>)b).TextScale = 0.72f; ((UITextPanel <LocalizedText>)b).TextColor = Color.Silver; }); this._submitButton2.Top.Pixels = 50f; this._submitButton2.PaddingLeft = 0.0f; this._submitButton2.PaddingRight = 0.0f; this.ValidateText(); this._submitButton2.OnMouseOver += (UIElement.MouseEvent)((evt, listeningElement) => this.ValidateText()); this._submitButton2.OnMouseOut += (UIElement.MouseEvent)((evt, listeningElement) => this.ValidateText()); this._submitButton2.OnClick += (UIElement.MouseEvent)((evt, listeningElement) => { string text = this.Text.Trim(); if (text.Length <= 0 && !this._edittingSign && (!this._edittingChest && !this._allowEmpty)) { return; } Main.PlaySound(10, -1, -1, 1, 1f, 0.0f); this._submitAction(text); }); this.outerLayer2.Append((UIElement)this._submitButton2); this._cancelButton2 = new UITextPanel <LocalizedText>(Language.GetText("UI.Cancel"), 0.72f, true); this._cancelButton2.TextColor = Color.Silver; this._cancelButton2.DrawPanel = false; this._cancelButton2.OnMouseOver += (UIElement.MouseEvent)((a, b) => { ((UITextPanel <LocalizedText>)b).TextScale = 0.85f; ((UITextPanel <LocalizedText>)b).TextColor = Color.White; }); this._cancelButton2.OnMouseOut += (UIElement.MouseEvent)((a, b) => { ((UITextPanel <LocalizedText>)b).TextScale = 0.72f; ((UITextPanel <LocalizedText>)b).TextColor = Color.Silver; }); this._cancelButton2.Height.Pixels = 60f; this._cancelButton2.Width.Precent = 0.4f; this._cancelButton2.Top.Pixels = 114f; this._cancelButton2.VAlign = 0.0f; this._cancelButton2.HAlign = 0.5f; this._cancelButton2.OnClick += (UIElement.MouseEvent)((evt, listeningElement) => { Main.PlaySound(11, -1, -1, 1, 1f, 0.0f); this._cancelAction(); }); this.outerLayer2.Append((UIElement)this._cancelButton2); UITextPanel <object> keyboardButton1 = this.CreateKeyboardButton((object)"", 8, 4, 2, true); keyboardButton1.OnClick += (UIElement.MouseEvent)((evt, listeningElement) => { Main.PlaySound(12, -1, -1, 1, 1f, 0.0f); this._textBox.Backspace(); this.ValidateText(); }); keyboardButton1.PaddingLeft = 0.0f; keyboardButton1.PaddingRight = 0.0f; keyboardButton1.PaddingBottom = keyboardButton1.PaddingTop = 0.0f; UIImage uiImage2 = new UIImage(this._textureBackspace); uiImage2.HAlign = 0.5f; uiImage2.VAlign = 0.5f; uiImage2.ImageScale = 0.92f; keyboardButton1.Append((UIElement)uiImage2); mainPanel.Append((UIElement)keyboardButton1); UIText uiText = new UIText(labelText, 0.75f, true); uiText.HAlign = 0.5f; uiText.Width.Pixels = num3; uiText.Top.Pixels = (float)((double)num4 - 37.0 - 4.0) + maxValue + num1; uiText.Top.Precent = num2; uiText.Height.Pixels = 37f; this.Append((UIElement)uiText); this._label = uiText; this.Append(element); this._textBox.SetTextMaxLength(this._edittingSign ? 99999 : 20); this.Text = startingText; if (this.Text.Length == 0) { this.SetKeyState(UIVirtualKeyboard.KeyState.Shift); } UIVirtualKeyboard.OffsetDown = 9999; this.UpdateOffsetDown(); }
/// <summary> /// Initialize the buttons for the menu. /// </summary> private void initializeButtons() { this.leftButton = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Left Button", new Vector2(this.xPositionOnScreen, this.yPositionOnScreen), new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "InventoryMenu", "PreviousPageButton"), new StardustCore.Animations.Animation(0, 0, 32, 32)), Color.White), new Rectangle(0, 0, 32, 32), 2f); this.rightButton = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Right Button", new Vector2(this.xPositionOnScreen + this.width, this.yPositionOnScreen), new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "InventoryMenu", "NextPageButton"), new StardustCore.Animations.Animation(0, 0, 32, 32)), Color.White), new Rectangle(0, 0, 32, 32), 2f); this.searchBox = new TextBox((Texture2D)null, (Texture2D)null, Game1.dialogueFont, Game1.textColor); this.searchBox.X = this.xPositionOnScreen + this.width + 96; this.searchBox.Y = this.yPositionOnScreen; this.searchBox.Width = 256; this.searchBox.Height = 192; Game1.keyboardDispatcher.Subscriber = (IKeyboardSubscriber)this.searchBox; this.searchBox.Selected = false; }
public static Mesh CreateCubeSingleTexture(float size, Vector3 position, Vector2 textureCoords) { Mesh mesh = new Mesh(); float s = size / 2f; mesh.SetVertices(new List <Vector3>() { new Vector3(-s, s, -s), // Front new Vector3(s, s, -s), // new Vector3(s, -s, -s), // new Vector3(-s, -s, -s), // new Vector3(-s, s, s), // Back new Vector3(s, s, s), // new Vector3(s, -s, s), // new Vector3(-s, -s, s), // new Vector3(-s, s, s), // Left new Vector3(-s, s, -s), // new Vector3(-s, -s, -s), // new Vector3(-s, -s, s), // new Vector3(s, s, s), // Right new Vector3(s, s, -s), // new Vector3(s, -s, -s), // new Vector3(s, -s, s), // new Vector3(-s, s, s), // Top new Vector3(-s, s, -s), // new Vector3(s, s, -s), // new Vector3(s, s, s), // new Vector3(-s, -s, s), // Bopttom new Vector3(-s, -s, -s), // new Vector3(s, -s, -s), // new Vector3(s, -s, s) // }); mesh.SetTriangles(new List <int>() { 0, 1, 3, // Front 1, 2, 3, // 7, 5, 4, // Back 7, 6, 5, // 8, 9, 11, // Left 9, 10, 11, // 15, 13, 12, // Right 15, 14, 13, // 19, 17, 16, // Top 19, 18, 17, // 20, 21, 23, // Bottom 21, 22, 23 // }, 0); float uMin = TextureManager.GetUVMin(textureCoords).x; float uMax = TextureManager.GetUVMax(textureCoords).x; float vMin = TextureManager.GetUVMin(textureCoords).y; float vMax = TextureManager.GetUVMax(textureCoords).y; mesh.SetUVs(0, new List <Vector2>() { new Vector2(uMin, vMax), // Front new Vector2(uMax, vMax), // new Vector2(uMax, vMin), // new Vector2(uMin, vMin), // new Vector2(uMax, vMax), // Back new Vector2(uMin, vMax), // new Vector2(uMin, vMin), // new Vector2(uMax, vMin), // new Vector2(uMin, vMax), // Left new Vector2(uMax, vMax), // new Vector2(uMax, vMin), // new Vector2(uMin, vMin), // new Vector2(uMax, vMax), // Right new Vector2(uMin, vMax), // new Vector2(uMin, vMin), // new Vector2(uMax, vMin), // new Vector2(uMin, vMax), // Top new Vector2(uMin, vMin), // new Vector2(uMax, vMin), // new Vector2(uMax, vMax), // new Vector2(uMin, vMin), // Bottom new Vector2(uMin, vMax), // new Vector2(uMax, vMax), // new Vector2(uMax, vMin), // }); mesh.SetNormals(new List <Vector3>() { Vector3.forward, Vector3.forward, Vector3.forward, Vector3.forward, Vector3.back, Vector3.back, Vector3.back, Vector3.back, Vector3.left, Vector3.left, Vector3.left, Vector3.left, Vector3.right, Vector3.right, Vector3.right, Vector3.right, Vector3.up, Vector3.up, Vector3.up, Vector3.up, Vector3.down, Vector3.down, Vector3.down, Vector3.down, }); mesh.RecalculateNormals(); mesh.RecalculateTangents(); return(mesh); }
public TextureManager (UnityImporter importer) { m_importer = importer; m_instance = this; }
/// <summary> /// 战斗场景的UI设置 /// </summary> /// <param name="tmng">纹理管理器</param> public BattleStageUI(TextureManager tmng) { texturemanager = tmng; }
/// <summary> /// Must be overriden by child classes for their own server specific startup behaviour. /// </summary> protected override void StartupComponents() { m_log.Info("[STARTUP]: Beginning startup processing"); Version = Util.EnhanceVersionInformation(); m_log.Info("[STARTUP]: Version: " + Version + "\n"); Console = new Console(this,"Region", this); IConfig cnf = m_configSource.Source.Configs["Startup"]; string loginURI = "http://127.0.0.1:9000/"; string firstName = string.Empty; string lastName = string.Empty; string password = string.Empty; string startlocation = ""; bool loadtextures = true; bool multipleSims = false; if (cnf != null) { loginURI = cnf.GetString("login_uri", ""); firstName = cnf.GetString("first_name", "test"); lastName = cnf.GetString("last_name", "user"); password = cnf.GetString("pass_word", "nopassword"); loadtextures = cnf.GetBoolean("load_textures", true); MeshSculpties = cnf.GetBoolean("mesh_sculpties", MeshSculpties); BackFaceCulling = cnf.GetBoolean("backface_culling", BackFaceCulling); AvatarMesh = cnf.GetString("avatar_mesh", AvatarMesh); AvatarMaterial = cnf.GetString("avatar_material", AvatarMaterial); AvatarScale = cnf.GetFloat("avatar_scale", AvatarScale); startlocation = cnf.GetString("start_location", ""); multipleSims = cnf.GetBoolean("multiple_sims", multipleSims); ProcessFoliage = cnf.GetBoolean("process_foliage", ProcessFoliage); m_limitFramesPerSecond = cnf.GetBoolean("limitfps", m_limitFramesPerSecond); } LoadTextures = loadtextures; MainConsole.Instance = Console; // Initialize LibOMV if (NetworkInterface == null) NetworkInterface = new RadegastNetworkModule(RInstance); NetworkInterface.MultipleSims = multipleSims; NetworkInterface.OnLandUpdate += OnNetworkLandUpdate; NetworkInterface.OnConnected += OnNetworkConnected; NetworkInterface.OnObjectAdd += OnNetworkObjectAdd; NetworkInterface.OnSimulatorConnected += OnNetworkSimulatorConnected; NetworkInterface.OnObjectUpdate += OnNetworkObjectUpdate; NetworkInterface.OnObjectRemove += OnNetworkObjectRemove; NetworkInterface.OnAvatarAdd += OnNetworkAvatarAdd; //NetworkInterface.OnChat +=new NetworkChatDelegate(OnNetworkChat); //NetworkInterface.OnFriendsListUpdate +=new NetworkFriendsListUpdateDelegate(OnNetworkFriendsListChange); //NetworkInterface.Login(loginURI, firstName + " " + lastName, password, startlocation); // Startup the GUI Renderer = new RaegastRenderer(this,Device); Renderer.Startup(); GUIFont defaultFont = Renderer.GuiEnvironment.GetFont("defaultfont.png"); skin = Renderer.GuiEnvironment.Skin; skin.Font = defaultFont; skincolor = skin.GetColor(GuiDefaultColor.Face3D); skincolor.A = 255; skin.SetColor(GuiDefaultColor.Face3D, skincolor); skincolor = skin.GetColor(GuiDefaultColor.Shadow3D); skincolor.A = 255; skin.SetColor(GuiDefaultColor.Shadow3D, skincolor); // Set up event handler for the GUI window events. Renderer.Device.OnEvent += new OnEventDelegate(OnDeviceEvent); Renderer.Device.Resizeable = true; MeshManager = new MeshManager(Renderer.SceneManager.MeshManipulator, Renderer.Device); SceneGraph = new VSceneGraph(this); // Set up the picker. SceneGraph.TrianglePicker = new TrianglePickerMapper(Renderer.SceneManager.CollisionManager); SceneGraph.TriangleSelector = Renderer.SceneManager.CreateMetaTriangleSelector(); // Only create a texture manager if the user configuration option is enabled for downloading textures if (LoadTextures) { TextureManager = new TextureManager(this,Renderer.Device, Renderer.Driver, SceneGraph.TrianglePicker, SceneGraph.TriangleSelector, "IdealistCache", NetworkInterface); TextureManager.OnTextureLoaded += OnNetworkTextureDownloaded; } AvatarController = new AvatarController(NetworkInterface, null); TerrainManager = ModuleManager.GetTerrainManager(this, m_configSource); Renderer.SceneManager.SetAmbientLight(new Colorf(1f, 0.2f, 0.2f, 0.2f)); // This light simulates the sun //SceneNode light2 = Renderer.SceneManager.AddLightSceneNode(Renderer.SceneManager.RootSceneNode, new Vector3D(0, 255, 0), new Colorf(0f, 0.5f, 0.5f, 0.5f), 250, -1); SceneNode light2 = Renderer.SceneManager.AddLightSceneNode(Renderer.SceneManager.RootSceneNode, new Vector3D(0, 255, 0), new Colorf(0f, 0.6f, 0.6f, 0.6f), 512, -1); // Fog is on by default, this line disables it. //Renderer.SceneManager.VideoDriver.SetFog(new Color(0, 255, 255, 255), false, 9999, 9999, 0, false, false); float fogBrightness = 0.8f; Renderer.SceneManager.VideoDriver.SetFog(new Color(0, (int)(0.5f * 255 * fogBrightness), (int)(0.5f * 255 * fogBrightness), (int)(1.0f * 255 * fogBrightness)), true, 50, 100, 0, true, true); //ATMOSkySceneNode skynode = new ATMOSkySceneNode(Renderer.Driver.GetTexture("irrlicht2_up.jpg"), null, Renderer.SceneManager, 100, -1); //ATMOSphere atmosphere = new ATMOSphere(Renderer.Device.Timer, null, Renderer.SceneManager, -1); //atmosphere.SkyTexture = Renderer.Driver.GetTexture("irrlicht2_up.jpg"); Renderer.Driver.SetTextureFlag(TextureCreationFlag.CreateMipMaps, false); bool Broken = false; if (!Broken) Renderer.SceneManager.AddSkyBoxSceneNode(null, new Texture[] { Renderer.Driver.GetTexture("topax2.jpg"), Renderer.Driver.GetTexture("irrlicht2_dn.jpg"), Renderer.Driver.GetTexture("rightax2.jpg"), Renderer.Driver.GetTexture("leftax2.jpg"), Renderer.Driver.GetTexture("frontax2.jpg"), Renderer.Driver.GetTexture("backax2.jpg")}, 0); Renderer.Driver.SetTextureFlag(TextureCreationFlag.CreateMipMaps, true); CameraController = new CameraController(this,Renderer.SceneManager); SceneGraph.WaterNode = new WaterSceneNode(null, Renderer.SceneManager, new Dimension2Df(180, 180), new Dimension2D(100, 100), new Dimension2D(512, 512)); SceneGraph.WaterNode.Position = new Vector3D(0, 30, 0); //SceneGraph.WaterNode.WaveHeight *= .4f; SceneGraph.WaterNode.RefractionFactor = 0.3f; SceneGraph.WaterNode.WaveDisplacement = 2f; SceneGraph.WaterNode.WaveHeight = 2f; SceneGraph.WaterNode.WaveLength = 2f; SceneGraph.WaterNode.WaveSpeed = 5f; SceneGraph.WaterNode.WaveRepetition = 20f; SceneGraph.WaterNode.Scale = new Vector3D(0.2f,0.2f,0.2f); SceneGraph.WaterNode.MultiColor = new Colorf(0.9f, 0.7f, 0.7f, 1.0f); UserInterface = new UserInterfaceManager(this, Renderer.Driver, Renderer.SceneManager, Renderer.GuiEnvironment, CameraController, AvatarController); UserInterface.DefaultFont = defaultFont; XmlReader xml = Broken? null: XmlReader.Create(new StreamReader("../../../media/About.xml")); while (xml != null && xml.Read()) { switch (xml.NodeType) { case XmlNodeType.Text: UserInterface.AboutText = xml.ReadContentAsString(); break; case XmlNodeType.Element: if (xml.Name.Equals("startUpModel")) { } else if (xml.Name.Equals("messageText")) UserInterface.AboutCaption = xml.GetAttribute("caption"); break; } } string formsUiConfigurationOption = m_configSource.Source.Configs["Startup"].GetString("forms", "true"); if (formsUiConfigurationOption == "true") { frmCommunications f = new frmCommunications(NetworkInterface); f.Visible = true; this.m_formsThread = new Thread(delegate() { Application.DoEvents(); Thread.Sleep(50); }); m_formsThread.Start(); } AnimationManager = new AnimationManager(this); TimeSpan timeTaken = DateTime.UtcNow - StartupTime; m_log.InfoFormat("[STARTUP]: Startup took {0}m {1}s", timeTaken.Minutes, timeTaken.Seconds); }
public FPSTestState(TextureManager textureManager) { _textureManager = textureManager; _font = new Font(textureManager.GetTexture("font"), FontParser.ParseFile("Assets/font.fnt")); _fpsText = new Text("FPS: ", _font); }
public UICharacterListItem(PlayerFileData data) { BorderColor = new Color(89, 116, 213) * 0.7f; _dividerTexture = TextureManager.Load("Images/UI/Divider"); _innerPanelTexture = TextureManager.Load("Images/UI/InnerPanelBackground"); _buttonCloudActiveTexture = TextureManager.Load("Images/UI/ButtonCloudActive"); _buttonCloudInactiveTexture = TextureManager.Load("Images/UI/ButtonCloudInactive"); _buttonFavoriteActiveTexture = TextureManager.Load("Images/UI/ButtonFavoriteActive"); _buttonFavoriteInactiveTexture = TextureManager.Load("Images/UI/ButtonFavoriteInactive"); _buttonPlayTexture = TextureManager.Load("Images/UI/ButtonPlay"); _buttonDeleteTexture = TextureManager.Load("Images/UI/ButtonDelete"); Height.Set(96f, 0f); Width.Set(0f, 1f); SetPadding(6f); _data = data; _playerPanel = new UICharacter(data.Player); _playerPanel.Left.Set(4f, 0f); _playerPanel.OnDoubleClick += PlayGame; base.OnDoubleClick += PlayGame; Append(_playerPanel); UIImageButton uIImageButton = new UIImageButton(_buttonPlayTexture); uIImageButton.VAlign = 1f; uIImageButton.Left.Set(4f, 0f); uIImageButton.OnClick += PlayGame; uIImageButton.OnMouseOver += PlayMouseOver; uIImageButton.OnMouseOut += ButtonMouseOut; Append(uIImageButton); UIImageButton uIImageButton2 = new UIImageButton(_data.IsFavorite ? _buttonFavoriteActiveTexture : _buttonFavoriteInactiveTexture); uIImageButton2.VAlign = 1f; uIImageButton2.Left.Set(28f, 0f); uIImageButton2.OnClick += FavoriteButtonClick; uIImageButton2.OnMouseOver += FavoriteMouseOver; uIImageButton2.OnMouseOut += ButtonMouseOut; uIImageButton2.SetVisibility(1f, _data.IsFavorite ? 0.8f : 0.4f); Append(uIImageButton2); if (SocialAPI.Cloud != null) { UIImageButton uIImageButton3 = new UIImageButton(_data.IsCloudSave ? _buttonCloudActiveTexture : _buttonCloudInactiveTexture); uIImageButton3.VAlign = 1f; uIImageButton3.Left.Set(52f, 0f); uIImageButton3.OnClick += CloudButtonClick; uIImageButton3.OnMouseOver += CloudMouseOver; uIImageButton3.OnMouseOut += ButtonMouseOut; Append(uIImageButton3); } UIImageButton uIImageButton4 = new UIImageButton(_buttonDeleteTexture); uIImageButton4.VAlign = 1f; uIImageButton4.HAlign = 1f; uIImageButton4.OnClick += DeleteButtonClick; uIImageButton4.OnMouseOver += DeleteMouseOver; uIImageButton4.OnMouseOut += DeleteMouseOut; _deleteButton = uIImageButton4; if (!_data.IsFavorite) { Append(uIImageButton4); } _buttonLabel = new UIText(""); _buttonLabel.VAlign = 1f; _buttonLabel.Left.Set(80f, 0f); _buttonLabel.Top.Set(-3f, 0f); Append(_buttonLabel); _deleteButtonLabel = new UIText(""); _deleteButtonLabel.VAlign = 1f; _deleteButtonLabel.HAlign = 1f; _deleteButtonLabel.Left.Set(-30f, 0f); _deleteButtonLabel.Top.Set(-3f, 0f); Append(_deleteButtonLabel); }
private float width, height; //宽和高(以最底层的为基础,为最大状态时的大小) #endregion Fields #region Constructors public Tree(TextureManager _t , Renderer _r , string name , bool isleft = true,float w = 150 ,float h= 150, float orix = 0, float oriy = 0) { if (random == null) random = new Random(); texturemanager = _t; renderer = _r; width = w; height = h; leaf = new Leaf[3]; Texture texture = texturemanager.Get(name); for (int i = 0; i < 3; i++) { leaf[i] = new Leaf(); leaf[i].leaf = new Sprite(); leaf[i].leaf.Texture = texture; if (isleft) leaf[i].leaf.SetUVs(0.51f, 0, 0.74f, 0.24f); else leaf[i].leaf.SetUVs(0.75f, 0, 0.99f, 0.24f); leaf[i].leaf.SetHeight(h); leaf[i].leaf.SetWidth(h); } }
/// <summary> /// Draw function to be called at each frame. /// </summary> public void Draw() { TextureManager.Draw(_tex, _src, Dst); }
public static void Init() { // init window Game.Window.SetDefaultOrthographicSize(20f); // add textures TextureManager.AddTexture("Player", new Texture(@"Assets\Player.png")); TextureManager.AddTexture("EnemyBlack2", new Texture(@"Assets\EnemyBlack2.png")); TextureManager.AddTexture("LaserRed01", new Texture(@"Assets\LaserRed01.png")); //add systems engine.AddSystem(new PlayerMoveSystem()); engine.AddSystem(new PlayerShootSystem()); engine.AddSystem(new AISpawnSystem()); engine.AddSystem(new AIMoveSystem()); engine.AddSystem(new DestroyEntityWhenOutOfScreenSystem()); engine.AddSystem(new CollisionDetectionSystem()); engine.AddSystem(new CollisionSolverSystem()); engine.AddSystem(new SpriteRendererSystem()); //create entities & add components #region Player ECSEntity player = engine.CreateEntity(); var halfOrthoSize = Game.Window.CurrentOrthoGraphicSize * 0.5f; engine.AddComponent(player, new NameComponent() { Name = "PLAYER" }); engine.AddComponent(player, new InputReceiverComponent()); engine.AddComponent(player, new PositionComponent() { Position = new Vector2(halfOrthoSize * Window.aspectRatio, halfOrthoSize * 1.5f) }); engine.AddComponent(player, new VelocityComponent() { Velocity = new Vector2(5f, 5f) }); engine.AddComponent(player, new BoxColliderComponent() { Size = new Vector2(1f, 1f) }); engine.AddComponent(player, new SpriteRendererComponent() { RenderOffset = RenderOffset.Player, Texture = TextureManager.GetTexture("Player"), Sprite = new Sprite(1f, 1f) { pivot = Vector2.One * 0.5f } }); engine.AddComponent(player, new WeaponComponent() { BulletSpawnOffset = new Vector2(0f, -1f) }); #endregion #region EnemySpawner(s) int spawnersCount = 5; float step = Game.Window.OrthoWidth / (float)(spawnersCount + 1); float offset = -1f; float minTime = 1f; float maxTime = 3f; for (int i = 0; i < spawnersCount; i++) { var spawner = engine.CreateEntity(); engine.AddComponent(spawner, new NameComponent() { Name = "SPAWNER " + i }); engine.AddComponent(spawner, new SpawnPointComponent() { SpawnPoint = new Vector2(step * (i + 1), offset) }); var time = (float)(minTime + Game.Random.NextDouble() * (maxTime - minTime)); engine.AddComponent(spawner, new TimeComponent() { Time = time, CurrentTime = time }); } #endregion // init engine Game.engine.Init(); }
internal static bool LoadSkin(string skin = null, bool clearCache = false) { InitializeSkinList(); bool found = true; if (skin == null || Skins.Find(s => s.Equals(skin, StringComparison.CurrentCultureIgnoreCase)) == null) { found = skin == null; skin = ConfigManager.sSkin; } bool forceDefault = false; if ((GameBase.Mode == OsuModes.Edit || GameBase.TestMode) && ConfigManager.sEditorDefaultSkin) { skin = DEFAULT_SKIN; forceDefault = true; } if (!Directory.Exists(Path.Combine(SKINS_FOLDER, skin))) { skin = DEFAULT_SKIN; forceDefault = true; } bool isNewSkin = false; if (clearCache || Current == null || !skin.Equals(Current.RawName, StringComparison.CurrentCultureIgnoreCase)) { if (Current != null) { Debug.Print(@"Skin reloaded"); } TextureManager.ClearSkinCache(true); SkinOsu newSkin = LoadSkinRaw(skin); if (newSkin != null) { isNewSkin = true; Current = newSkin; if (skin == ConfigManager.sSkin) { CurrentUserSkin = Current; } AudioEngine.ClearSkinCache(); if (GameBase.Mode == OsuModes.Play) //todo: check if we actually need to load samples here. { AudioEngine.LoadAllSamples(); } else { AudioEngine.LoadPrioritySamples(); } } } BeatmapColours.Clear(); ResetColoursToSkin(); if (ConfigManager.sUseSkinCursor && Current != CurrentUserSkin && !forceDefault) { //Special user override. SkinOsu tempHolder = Current; Current = CurrentUserSkin; LoadCursor(); Current = tempHolder; } else { LoadCursor(); } if (isNewSkin) { OnSkinChanged?.Invoke(); } return(found); }
public void UnloadTextures() { Input.DirectKeyCode -= KeyCode; TextureManager.UnRegisterTextures(textures); }
internal static void ClearAllCache() { TextureManager.ClearSkinCache(true); TextureManager.ClearDefaultCache(true); LoadCursor(true); }
private void checkImageElements() { string[] files = Directory.GetFiles(BeatmapManager.Current.ContainingFolderAbsolute, @"*", SearchOption.AllDirectories); Dictionary <string, bool> fileDict = new Dictionary <string, bool>(files.Length); foreach (string file in files) { FileType ext = GeneralHelper.GetFileType(file); if (ext != FileType.Image) { continue; } string strippedFilename = GeneralHelper.PathSanitise(GeneralHelper.GetRelativePath(file, BeatmapManager.Current.ContainingFolderAbsolute)); string fileKey = strippedFilename.ToLower(); fileDict[fileKey] = true; int scale = 1; string name = strippedFilename; if (name.Contains(@"@2x")) { scale = 2; name = name.Replace(@"@2x", string.Empty); } switch (name.ToLower()) { case @"hitcircle": case @"hitcircleoverlay": case @"approachcircle": case @"reversearrow": pTexture p = TextureManager.Load(strippedFilename, SkinSource.Beatmap); if (p != null && (p.DisplayWidth != 128 * scale || p.DisplayHeight != 128 * scale)) { addSkinReport(strippedFilename, 128 * scale); } break; } } //sprite events check EventManager manager = Editor.Instance.eventManager; for (int i = 0; i < manager.storyLayerSprites.Length; i++) { for (int j = 0; j < manager.storyLayerSprites[i].Count; j++) { Event e = manager.storyLayerSprites[i][j]; string name = e.Filename; string fileKey = name.ToLower(); if (!fileDict.ContainsKey(fileKey)) { if (BeatmapManager.Current.UseSkinSpritesInSB) { if (TextureManager.Load(name, SkinSource.Osu | SkinSource.Beatmap) != null) { continue; } if (TextureManager.LoadAll(name, SkinSource.Osu | SkinSource.Beatmap, false) != null) { continue; } } else // check for sprite animation { int animationSuffix = name.LastIndexOf('.'); if (animationSuffix >= 0 && fileDict.ContainsKey(fileKey.Insert(animationSuffix, "0")) && fileDict.ContainsKey(fileKey.Insert(animationSuffix, "1"))) { continue; // at least two frames of sprite animation detected, don't display missing file warning } } fileDict[fileKey] = true; // add fake file,ensure file missing just report once. Reports.Add(new AiReport(Severity.Error, LocalisationManager.GetString(OsuString.AIDesign_FileMissing) + name)); } } } }
public void InitializePage() { this.RemoveAllChildren(); this._categoryButtons.Clear(); this._achievementElements.Clear(); this._achievementsList = (UIList)null; var largeForOtherLanguages = true; var num = largeForOtherLanguages.ToInt() * 100; var element1 = new UIElement(); element1.Width.Set(0.0f, 0.8f); element1.MaxWidth.Set(800f + (float)num, 0.0f); element1.MinWidth.Set(600f + (float)num, 0.0f); element1.Top.Set(220f, 0.0f); element1.Height.Set(-220f, 1f); element1.HAlign = 0.5f; this._outerContainer = element1; this.Append(element1); var uiPanel = new UIPanel(); uiPanel.Width.Set(0.0f, 1f); uiPanel.Height.Set(-110f, 1f); uiPanel.BackgroundColor = new Color(33, 43, 79) * 0.8f; uiPanel.PaddingTop = 0.0f; element1.Append((UIElement)uiPanel); this._achievementsList = new UIList(); this._achievementsList.Width.Set(-25f, 1f); this._achievementsList.Height.Set(-50f, 1f); this._achievementsList.Top.Set(50f, 0.0f); this._achievementsList.ListPadding = 5f; uiPanel.Append((UIElement)this._achievementsList); var uiTextPanel1 = new UITextPanel <LocalizedText>(Language.GetText("UI.Achievements"), 1f, true); uiTextPanel1.HAlign = 0.5f; uiTextPanel1.Top.Set(-33f, 0.0f); uiTextPanel1.SetPadding(13f); uiTextPanel1.BackgroundColor = new Color(73, 94, 171); element1.Append((UIElement)uiTextPanel1); var uiTextPanel2 = new UITextPanel <LocalizedText>(Language.GetText("UI.Back"), 0.7f, true); uiTextPanel2.Width.Set(-10f, 0.5f); uiTextPanel2.Height.Set(50f, 0.0f); uiTextPanel2.VAlign = 1f; uiTextPanel2.HAlign = 0.5f; uiTextPanel2.Top.Set(-45f, 0.0f); uiTextPanel2.OnMouseOver += new UIElement.MouseEvent(this.FadedMouseOver); uiTextPanel2.OnMouseOut += new UIElement.MouseEvent(this.FadedMouseOut); uiTextPanel2.OnClick += new UIElement.MouseEvent(this.GoBackClick); element1.Append((UIElement)uiTextPanel2); this._backpanel = (UIElement)uiTextPanel2; var achievementsList = Main.Achievements.CreateAchievementsList(); for (var index = 0; index < achievementsList.Count; ++index) { var achievementListItem = new UIAchievementListItem(achievementsList[index], largeForOtherLanguages); this._achievementsList.Add((UIElement)achievementListItem); this._achievementElements.Add(achievementListItem); } var scrollbar = new UIScrollbar(); scrollbar.SetView(100f, 1000f); scrollbar.Height.Set(-50f, 1f); scrollbar.Top.Set(50f, 0.0f); scrollbar.HAlign = 1f; uiPanel.Append((UIElement)scrollbar); this._achievementsList.SetScrollbar(scrollbar); var element2 = new UIElement(); element2.Width.Set(0.0f, 1f); element2.Height.Set(32f, 0.0f); element2.Top.Set(10f, 0.0f); var texture = TextureManager.Load("Images/UI/Achievement_Categories"); for (var index = 0; index < 4; ++index) { var uiToggleImage = new UIToggleImage(texture, 32, 32, new Point(34 * index, 0), new Point(34 * index, 34)); uiToggleImage.Left.Set((float)(index * 36 + 8), 0.0f); uiToggleImage.SetState(true); uiToggleImage.OnClick += new UIElement.MouseEvent(this.FilterList); this._categoryButtons.Add(uiToggleImage); element2.Append((UIElement)uiToggleImage); } uiPanel.Append(element2); }
// Token: 0x06000DB9 RID: 3513 RVA: 0x003E636C File Offset: 0x003E456C public ScreenShaderData UseImage(string path, int index = 0, SamplerState samplerState = null) { this._uImages[index] = TextureManager.AsyncLoad(path); this._samplerStates[index] = samplerState; return(this); }
public FontDemoState(TextureManager textureManager) { _textureManager = textureManager; _font = new Font(textureManager.GetTexture("font"), FontParser.ParseFile("Assets/font.fnt")); _helloWorld = new Text("The quick brown fox jumps over the lazy dog", _font, new Color(1, 0, 0, 1), 400); }
public UIModPackItem(string name, string[] mods) { this.filename = name; this.mods = mods; this.numMods = mods.Length; modMissing = new bool[mods.Length]; numModsEnabled = 0; numModsDisabled = 0; numModsMissing = 0; for (int i = 0; i < mods.Length; i++) { if (UIModPacks.mods.Contains(mods[i])) { if (ModLoader.IsEnabled(mods[i])) { numModsEnabled++; } else { numModsDisabled++; } } else { modMissing[i] = true; numModsMissing++; } } this.BorderColor = new Color(89, 116, 213) * 0.7f; this.dividerTexture = TextureManager.Load("Images/UI/Divider"); this.innerPanelTexture = TextureManager.Load("Images/UI/InnerPanelBackground"); this.Height.Set(126f, 0f); this.Width.Set(0f, 1f); base.SetPadding(6f); this.modName = new UIText(name, 1f, false); this.modName.Left.Set(10f, 0f); this.modName.Top.Set(5f, 0f); base.Append(this.modName); UITextPanel <string> viewListButton = new UITextPanel <string>("View List", 1f, false); viewListButton.Width.Set(100f, 0f); viewListButton.Height.Set(30f, 0f); viewListButton.Left.Set(430f, 0f); viewListButton.Top.Set(40f, 0f); viewListButton.PaddingTop -= 2f; viewListButton.PaddingBottom -= 2f; viewListButton.OnMouseOver += UICommon.FadedMouseOver; viewListButton.OnMouseOut += UICommon.FadedMouseOut; viewListButton.OnClick += ViewListInfo; base.Append(viewListButton); enableListButton = new UITextPanel <string>("Enable this List", 1f, false); enableListButton.Width.Set(100f, 0f); enableListButton.Height.Set(30f, 0f); enableListButton.Left.Set(273f, 0f); enableListButton.Top.Set(40f, 0f); enableListButton.PaddingTop -= 2f; enableListButton.PaddingBottom -= 2f; enableListButton.OnMouseOver += UICommon.FadedMouseOver; enableListButton.OnMouseOut += UICommon.FadedMouseOut; enableListButton.OnClick += EnableList; base.Append(enableListButton); enableListOnlyButton = new UITextPanel <string>("Enable only this List", 1f, false); enableListOnlyButton.Width.Set(100f, 0f); enableListOnlyButton.Height.Set(30f, 0f); enableListOnlyButton.Left.Set(75f, 0f); enableListOnlyButton.Top.Set(40f, 0f); enableListOnlyButton.PaddingTop -= 2f; enableListOnlyButton.PaddingBottom -= 2f; enableListOnlyButton.OnMouseOver += UICommon.FadedMouseOver; enableListOnlyButton.OnMouseOut += UICommon.FadedMouseOut; enableListOnlyButton.OnClick += EnableListOnly; base.Append(enableListOnlyButton); viewInModBrowserButton = new UITextPanel <string>("View Mods in Mod Browser", 1f, false); viewInModBrowserButton.Width.Set(50f, 0f); viewInModBrowserButton.Height.Set(30f, 0f); viewInModBrowserButton.Left.Set(75f, 0f); viewInModBrowserButton.Top.Set(80f, 0f); viewInModBrowserButton.PaddingTop -= 2f; viewInModBrowserButton.PaddingBottom -= 2f; viewInModBrowserButton.OnMouseOver += UICommon.FadedMouseOver; viewInModBrowserButton.OnMouseOut += UICommon.FadedMouseOut; viewInModBrowserButton.OnClick += ViewInModBrowser; base.Append(viewInModBrowserButton); deleteButton = new UIImageButton(TextureManager.Load("Images/UI/ButtonDelete")); deleteButton.Top.Set(40f, 0f); deleteButton.OnClick += this.DeleteButtonClick; base.Append(deleteButton); }
public littleStar(TextureManager _t, int color) { name = "littleStar"; Texture texture = _t.Get("etama6"); sprite = new Sprite(); sprite.Texture = texture; sprite.SetWidth(16); sprite.SetHeight(16); if (color > 15) color = 15; if (color < 0) color = 0; sprite.SetUVs(color * 2 * per_256, 0, (color + 1) * 2 * per_256, 2 * per_256); this.color = color; }
private void initializeStatics() { //const int textx1 = 80; const int imgx1 = 40; //const int textx2 = 280; const int imgx2 = 240; const int row1 = 160; const int row2 = 220; const int row3 = 280; const int row4 = 320; int timeOffset = 1000; float staticScale = 0.65f; Vector2 tMove = new Vector2(40, 0); const int length = 400; int startTime = GameBase.Time; pSprite p; Transformation t; bool isFruits = playMode == PlayModes.CatchTheBeat; //offset for the first panel int offsetX = 0; int secondSpritesOffset = 0; //draw statics for both panels for (int i = 0; i < 2; i++) { timeOffset = 1000; if (isFruits) { p = new pSprite(TextureManager.Load(@"fruit-orange"), Fields.TopLeft, Origins.Centre, Clocks.Game, new Vector2(imgx1, row1), 0.9F, true, Color.Orange); p.Alpha = 0; t = new Transformation(TransformationType.Scale, 1.2f * staticScale, 0.65F * staticScale, startTime + timeOffset, startTime + timeOffset + length); t.Easing = EasingTypes.In; p.Transformations.Add(t); t = new Transformation(TransformationType.Fade, 0, 1, startTime + timeOffset, startTime + timeOffset + length); t.Easing = EasingTypes.In; p.Transformations.Add(t); staticSprites.Add(p); p = new pSprite(TextureManager.Load(@"fruit-orange-overlay"), Fields.TopLeft, Origins.Centre, Clocks.Game, new Vector2(imgx1, row1), 0.91F, true, Color.TransparentWhite); t = new Transformation(TransformationType.Scale, 1.2f * staticScale, 0.65F * staticScale, startTime + timeOffset, startTime + timeOffset + length); t.Easing = EasingTypes.In; p.Transformations.Add(t); t = new Transformation(TransformationType.Fade, 0, 1, startTime + timeOffset, startTime + timeOffset + length); timeOffset += length; t.Easing = EasingTypes.In; p.Transformations.Add(t); staticSprites.Add(p); p = new pSprite(TextureManager.Load(@"fruit-drop"), Fields.TopLeft, Origins.Centre, Clocks.Game, new Vector2(imgx1, row2), 0.9F, true, Color.YellowGreen); p.Alpha = 0; t = new Transformation(TransformationType.Scale, 1.2f * staticScale, 0.77F * staticScale, startTime + timeOffset, startTime + timeOffset + length); t.Easing = EasingTypes.In; p.Transformations.Add(t); t = new Transformation(TransformationType.Fade, 0, 1, startTime + timeOffset, startTime + timeOffset + length); timeOffset += length; t.Easing = EasingTypes.In; p.Transformations.Add(t); staticSprites.Add(p); p = new pSprite(TextureManager.Load(@"fruit-drop"), Fields.TopLeft, Origins.Centre, Clocks.Game, new Vector2(imgx1, row3), 0.9F, true, Color.LightBlue); p.Alpha = 0; p.Rotation = 4; t = new Transformation(TransformationType.Scale, 1.15f * staticScale, 0.57F * staticScale, startTime + timeOffset, startTime + timeOffset + length); t.Easing = EasingTypes.In; p.Transformations.Add(t); t = new Transformation(TransformationType.Fade, 0, 1, startTime + timeOffset, startTime + timeOffset + length); timeOffset += length; t.Easing = EasingTypes.In; p.Transformations.Add(t); staticSprites.Add(p); p = new pSprite(TextureManager.Load(@"fruit-orange"), Fields.TopLeft, Origins.Centre, Clocks.Game, new Vector2(imgx2, row1), 0.9F, true, Color.LightGray); p.Alpha = 0; p.Rotation = 0.8f; t = new Transformation(TransformationType.Scale, 1.15f * staticScale, 0.57F * staticScale, startTime + timeOffset, startTime + timeOffset + length); t.Easing = EasingTypes.In; p.Transformations.Add(t); t = new Transformation(TransformationType.Fade, 0, 1, startTime + timeOffset, startTime + timeOffset + length); t.Easing = EasingTypes.In; p.Transformations.Add(t); staticSprites.Add(p); p = new pSprite(TextureManager.Load(@"fruit-orange-overlay"), Fields.TopLeft, Origins.Centre, Clocks.Game, new Vector2(imgx2, row1), 0.91F, true, Color.TransparentWhite); p.Rotation = 0.8f; t = new Transformation(TransformationType.Scale, 1.15f * staticScale, 0.57F * staticScale, startTime + timeOffset, startTime + timeOffset + length); t.Easing = EasingTypes.In; p.Transformations.Add(t); t = new Transformation(TransformationType.Fade, 0, 1, startTime + timeOffset, startTime + timeOffset + length); t.Easing = EasingTypes.In; p.Transformations.Add(t); staticSprites.Add(p); p = new pSprite(TextureManager.Load(@"hit0"), Fields.TopLeft, Origins.Centre, Clocks.Game, new Vector2(imgx2, row1) - new Vector2(20, 20), 0.9F, true, Color.TransparentWhite); t = new Transformation(TransformationType.Scale, 0.9f * staticScale, 0.35F * staticScale, startTime + timeOffset, startTime + timeOffset + length); t.Easing = EasingTypes.In; p.Transformations.Add(t); t = new Transformation(TransformationType.Fade, 0, 1, startTime + timeOffset, startTime + timeOffset + length); timeOffset += length; t.Easing = EasingTypes.In; p.Transformations.Add(t); staticSprites.Add(p); } else { p = new pSprite(TextureManager.Load(@"hit300"), Fields.TopLeft, Origins.Centre, Clocks.Game, new Vector2(imgx1, row1), 0.9F, true, Color.TransparentWhite); t = new Transformation(TransformationType.Scale, 1 * staticScale, 0.5F * staticScale, startTime + timeOffset, startTime + timeOffset + length); t.Easing = EasingTypes.In; p.Transformations.Add(t); t = new Transformation(TransformationType.Fade, 0, 1, startTime + timeOffset, startTime + timeOffset + length); timeOffset += length; t.Easing = EasingTypes.In; p.Transformations.Add(t); staticSprites.Add(p); p = new pSprite(TextureManager.Load(@"hit100"), Fields.TopLeft, Origins.Centre, Clocks.Game, new Vector2(imgx1, row2), 0.9F, true, Color.TransparentWhite); t = new Transformation(TransformationType.Scale, 1 * staticScale, 0.5F * staticScale, startTime + timeOffset, startTime + timeOffset + length); t.Easing = EasingTypes.In; p.Transformations.Add(t); t = new Transformation(TransformationType.Fade, 0, 1, startTime + timeOffset, startTime + timeOffset + length); timeOffset += length; t.Easing = EasingTypes.In; p.Transformations.Add(t); staticSprites.Add(p); p = new pSprite(TextureManager.Load(@"hit50"), Fields.TopLeft, Origins.Centre, Clocks.Game, new Vector2(imgx1, row3), 0.9F, true, Color.TransparentWhite); t = new Transformation(TransformationType.Scale, 1 * staticScale, 0.5F * staticScale, startTime + timeOffset, startTime + timeOffset + length); t.Easing = EasingTypes.In; p.Transformations.Add(t); t = new Transformation(TransformationType.Fade, 0, 1, startTime + timeOffset, startTime + timeOffset + length); timeOffset += length; t.Easing = EasingTypes.In; p.Transformations.Add(t); staticSprites.Add(p); p = new pSprite(TextureManager.Load(@"hit300g"), Fields.TopLeft, Origins.Centre, Clocks.Game, new Vector2(imgx2, row1), 0.9F, true, Color.TransparentWhite); t = new Transformation(TransformationType.Scale, 1 * staticScale, 0.5F * staticScale, startTime + timeOffset, startTime + timeOffset + length); t.Easing = EasingTypes.In; p.Transformations.Add(t); t = new Transformation(TransformationType.Fade, 0, 1, startTime + timeOffset, startTime + timeOffset + length); timeOffset += length; t.Easing = EasingTypes.In; p.Transformations.Add(t); staticSprites.Add(p); p = new pSprite(TextureManager.Load(@"hit100k"), Fields.TopLeft, Origins.Centre, Clocks.Game, new Vector2(imgx2, row2), 0.9F, true, Color.TransparentWhite); t = new Transformation(TransformationType.Scale, 1 * staticScale, 0.5F * staticScale, startTime + timeOffset, startTime + timeOffset + length); t.Easing = EasingTypes.In; p.Transformations.Add(t); t = new Transformation(TransformationType.Fade, 0, 1, startTime + timeOffset, startTime + timeOffset + length); timeOffset += length; t.Easing = EasingTypes.In; p.Transformations.Add(t); staticSprites.Add(p); p = new pSprite(TextureManager.Load(@"hit0"), Fields.TopLeft, Origins.Centre, Clocks.Game, new Vector2(imgx2, row3), 0.9F, true, Color.TransparentWhite); t = new Transformation(TransformationType.Scale, 1 * staticScale, 0.5F * staticScale, startTime + timeOffset, startTime + timeOffset + length); t.Easing = EasingTypes.In; p.Transformations.Add(t); t = new Transformation(TransformationType.Fade, 0, 1, startTime + timeOffset, startTime + timeOffset + length); timeOffset += length; t.Easing = EasingTypes.In; p.Transformations.Add(t); staticSprites.Add(p); } p = new pSprite(TextureManager.Load(@"ranking-maxcombo"), Fields.TopLeft, Origins.TopLeft, Clocks.Game, new Vector2(imgx1 - 35, row4 - (SkinManager.UseNewLayout ? 20 : 8)), 0.81F, true, Color.TransparentWhite); t = new Transformation(TransformationType.Fade, 0, 1, startTime + timeOffset, startTime + timeOffset + length); timeOffset += length; t.Easing = EasingTypes.In; p.Transformations.Add(t); staticSprites.Add(p); p = new pSprite(TextureManager.Load(@"ranking-accuracy"), Fields.TopLeft, Origins.TopLeft, Clocks.Game, new Vector2(imgx2 - 58, row4 - (SkinManager.UseNewLayout ? 20 : 8)), 0.81F, true, Color.TransparentWhite); t = new Transformation(TransformationType.Fade, 0, 1, startTime + timeOffset, startTime + timeOffset + length); timeOffset += length; t.Easing = EasingTypes.In; p.Transformations.Add(t); staticSprites.Add(p); rankingGraphPosition = new Vector2(56, SkinManager.UseNewLayout ? 415 : 375); p = new pSprite(TextureManager.Load(@"ranking-graph"), Fields.TopLeft, Origins.TopLeft, Clocks.Game, rankingGraphPosition, 0.8F, true, Color.White); p.Scale = 1.22f; staticSprites.Add(p); float scale = 0.60f * 1.10f; //the lazy way to get the positions and scale right int j = 0; for (j = secondSpritesOffset; j < staticSprites.Count; j++) { pSprite pp = staticSprites[j]; pp.Scale *= scale; pp.Position.X = imgx1 + (pp.Position.X - imgx1) * scale + offsetX; pp.Position.Y = row1 + (pp.Position.Y - row1) * scale + 18; spriteManagerWideScrolling.Add(pp); } secondSpritesOffset = j; //offset for the second panel offsetX = GameBase.WindowManager.WidthScaled - 279; } }
public void Initialize() { if (PreInitEvent != null) PreInitEvent(null, EventArgs.Empty); _textureManager = TextureManager.GetInstance(_sceneName); OnInit(); _isInitialized = true; if (InitCompleteEvent != null) InitCompleteEvent(null, EventArgs.Empty); }
public override void Initialize() { base.Initialize(); Player.ScoreBoard.spriteManager.WidescreenAutoOffset = true; Player.ScoreBoard.spriteManager.Alpha = 1; lock (StreamingManager.LockReplayScore) { InputManager.ReplayMode = false; InputManager.ReplayStreaming = false; InputManager.ReplayStartTime = 0; } pText text = null; SlotTeams winner = PlayerVs.TeamOverlay.winner; if (PlayerVs.TeamFailed(SlotTeams.Blue)) { text = new pText("Blue team failed!", 20, new Vector2(GameBase.WindowManager.WidthScaled / 2, 85), Vector2.Zero, 1, true, Color.Blue, false); } else if (PlayerVs.TeamFailed(SlotTeams.Red)) { text = new pText("Red team failed!", 20, new Vector2(GameBase.WindowManager.WidthScaled / 2, 85), Vector2.Zero, 1, true, Color.Red, false); } else { switch (winner) { case SlotTeams.Blue: text = new pText("Blue team wins!", 20, new Vector2(GameBase.WindowManager.WidthScaled / 2, 85), Vector2.Zero, 1, true, Color.Blue, false); break; case SlotTeams.Red: text = new pText("Red team wins!", 20, new Vector2(GameBase.WindowManager.WidthScaled / 2, 85), Vector2.Zero, 1, true, Color.Red, false); break; } } text.TextBold = true; text.Origin = Origins.Centre; spriteManagerWideScrolling.Add(text); int tabHeight = 113; //add team1Tabs = new pTabCollection(spriteManagerWideScrolling, 3, new Vector2(56, tabHeight), 0.8f, true, Color.BlueViolet, 40); team2Tabs = new pTabCollection(spriteManagerWideScrolling, 3, new Vector2(GameBase.WindowManager.WidthScaled - 224, tabHeight), 0.8f, true, Color.BlueViolet, 40); team1Tabs.Add("Total", 0); team2Tabs.Add("Total", 0); team1Tabs.SetSelected(0); team2Tabs.SetSelected(0); team1Tabs.OnTabChanged += delegate(object sender, EventArgs e) { loadScores(SlotTeams.Blue, (int)sender, false); }; team2Tabs.OnTabChanged += delegate(object sender, EventArgs e) { loadScores(SlotTeams.Red, (int)sender, false); }; int count = PlayerVs.LastScoreEntries.Count; for (int i = 0; i < count; i++) { ScoreboardEntry entry = PlayerVs.LastScoreEntries[i]; if (entry != null) { (entry.Team == SlotTeams.Blue ? team1Tabs : team2Tabs).Add(entry.name, i + 1); } } pSprite scoreBackground1 = new pSprite(TextureManager.Load(@"ranking-panel"), Fields.TopLeft, Origins.TopLeft, Clocks.Game, new Vector2(1, SkinManager.UseNewLayout ? 107 : 97), 0.79f, true, Color.White); scoreBackground1.Alpha = 1.0f; scoreBackground1.VectorScale = new Vector2(0.715f, 0.77f); pSprite scoreBackground2 = new pSprite(TextureManager.Load(@"ranking-panel"), Fields.TopLeft, Origins.TopLeft, Clocks.Game, new Vector2(GameBase.WindowManager.WidthScaled - 279, SkinManager.UseNewLayout ? 107 : 97), 0.79f, true, Color.White); scoreBackground2.Alpha = 1.0f; scoreBackground2.VectorScale = new Vector2(0.715f, 0.77f); spriteManagerWideScrolling.Add(scoreBackground1); spriteManagerWideScrolling.Add(scoreBackground2); initializeStatics(); //cache scores for more efficiency team1Score = getTeamScore(SlotTeams.Blue); team2Score = getTeamScore(SlotTeams.Red); loadScores(SlotTeams.Blue, 0, true); loadScores(SlotTeams.Red, 0, true); playMode = Player.Mode; }
public BackGroundImage(TextureManager _t ,Renderer _renderer, string TextureName , Rectangle UVs, float width = 385, float height = 450) { texturemanager = _t; renderer = _renderer; current_rect = new Rectangle(0.1f, 0, 0.8f, 0.8f); this.UVs = UVs; this.width = width; this.height = height; map_up = new Sprite(); map_up.Texture = texturemanager.Get(TextureName); map_up.SetWidth(width); map_up.SetHeight(height); map_up.SetPosition(X, Y); map_up.SetUVs(new Point(current_rect.X , current_rect.Y), new Point(current_rect.X+current_rect.Width, current_rect.Y+ current_rect.Height)); map_down = new Sprite(); map_down.Texture = texturemanager.Get(TextureName); map_down.SetWidth(width); map_down.SetHeight(height); map_down.SetPosition(X, Y); map_down.SetUVs(new Point(current_rect.X, current_rect.Y), new Point(current_rect.X + current_rect.Width, current_rect.Y + current_rect.Height)); }
public static Mesh CreateCubeSidedTexture(float size, Vector3 position, Vector2 textureCoordsFront, Vector2 textureCoordsBack, Vector2 textureCoordsLeft, Vector2 textureCoordsRight, Vector2 textureCoordsTop, Vector2 textureCoordsBottom) { Mesh mesh = new Mesh(); float s = size / 2f; List <Vector3> verts = new List <Vector3>() { new Vector3(-s, s, -s), // Front new Vector3(s, s, -s), // new Vector3(s, -s, -s), // new Vector3(-s, -s, -s), // new Vector3(-s, s, s), // Back new Vector3(s, s, s), // new Vector3(s, -s, s), // new Vector3(-s, -s, s), // new Vector3(-s, s, s), // Left new Vector3(-s, s, -s), // new Vector3(-s, -s, -s), // new Vector3(-s, -s, s), // new Vector3(s, s, s), // Right new Vector3(s, s, -s), // new Vector3(s, -s, -s), // new Vector3(s, -s, s), // new Vector3(-s, s, s), // Top new Vector3(-s, s, -s), // new Vector3(s, s, -s), // new Vector3(s, s, s), // new Vector3(-s, -s, s), // Bopttom new Vector3(-s, -s, -s), // new Vector3(s, -s, -s), // new Vector3(s, -s, s) // }; for (int i = 0; i < verts.Count; i++) { verts[i] += position; } mesh.SetVertices(verts); mesh.SetTriangles(new List <int>() { 0, 1, 3, // Front 1, 2, 3, // 7, 5, 4, // Back 7, 6, 5, // 8, 9, 11, // Left 9, 10, 11, // 15, 13, 12, // Right 15, 14, 13, // 19, 17, 16, // Top 19, 18, 17, // 20, 21, 23, // Bottom 21, 22, 23 // }, 0); List <Vector2> UVCoordsList = new List <Vector2>(); float uMin = TextureManager.GetUVMin(textureCoordsFront).x; float uMax = TextureManager.GetUVMax(textureCoordsFront).x; float vMin = TextureManager.GetUVMin(textureCoordsFront).y; float vMax = TextureManager.GetUVMax(textureCoordsFront).y; UVCoordsList.AddRange(new List <Vector2>() { new Vector2(uMin, vMax), new Vector2(uMax, vMax), new Vector2(uMax, vMin), new Vector2(uMin, vMin) }); uMin = TextureManager.GetUVMin(textureCoordsBack).x; uMax = TextureManager.GetUVMax(textureCoordsBack).x; vMin = TextureManager.GetUVMin(textureCoordsBack).y; vMax = TextureManager.GetUVMax(textureCoordsBack).y; UVCoordsList.AddRange(new List <Vector2>() { new Vector2(uMax, vMax), new Vector2(uMin, vMax), new Vector2(uMin, vMin), new Vector2(uMax, vMin) }); uMin = TextureManager.GetUVMin(textureCoordsLeft).x; uMax = TextureManager.GetUVMax(textureCoordsLeft).x; vMin = TextureManager.GetUVMin(textureCoordsLeft).y; vMax = TextureManager.GetUVMax(textureCoordsLeft).y; UVCoordsList.AddRange(new List <Vector2>() { new Vector2(uMin, vMax), new Vector2(uMax, vMax), new Vector2(uMax, vMin), new Vector2(uMin, vMin) }); uMin = TextureManager.GetUVMin(textureCoordsRight).x; uMax = TextureManager.GetUVMax(textureCoordsRight).x; vMin = TextureManager.GetUVMin(textureCoordsRight).y; vMax = TextureManager.GetUVMax(textureCoordsRight).y; UVCoordsList.AddRange(new List <Vector2>() { new Vector2(uMax, vMax), // Right new Vector2(uMin, vMax), // new Vector2(uMin, vMin), // new Vector2(uMax, vMin), // }); uMin = TextureManager.GetUVMin(textureCoordsTop).x; uMax = TextureManager.GetUVMax(textureCoordsTop).x; vMin = TextureManager.GetUVMin(textureCoordsTop).y; vMax = TextureManager.GetUVMax(textureCoordsTop).y; UVCoordsList.AddRange(new List <Vector2>() { new Vector2(uMin, vMax), // Top new Vector2(uMin, vMin), // new Vector2(uMax, vMin), // new Vector2(uMax, vMax), // }); uMin = TextureManager.GetUVMin(textureCoordsBottom).x; uMax = TextureManager.GetUVMax(textureCoordsBottom).x; vMin = TextureManager.GetUVMin(textureCoordsBottom).y; vMax = TextureManager.GetUVMax(textureCoordsBottom).y; UVCoordsList.AddRange(new List <Vector2>() { new Vector2(uMin, vMin), // Bottom new Vector2(uMin, vMax), // new Vector2(uMax, vMax), // new Vector2(uMax, vMin), // }); mesh.SetUVs(0, UVCoordsList); mesh.SetNormals(new List <Vector3>() { Vector3.forward, Vector3.forward, Vector3.forward, Vector3.forward, Vector3.back, Vector3.back, Vector3.back, Vector3.back, Vector3.left, Vector3.left, Vector3.left, Vector3.left, Vector3.right, Vector3.right, Vector3.right, Vector3.right, Vector3.up, Vector3.up, Vector3.up, Vector3.up, Vector3.down, Vector3.down, Vector3.down, Vector3.down, }); mesh.RecalculateNormals(); mesh.RecalculateTangents(); return(mesh); }
public BackGroundImage3D(TextureManager _t, Renderer _renderer, string TextureName, float width = 385, float height = 450) { texturemanager = _t; renderer = _renderer; this.width = width; this.height = height; Sprite sp; sp = new Sprite(); sp.Texture = texturemanager.Get(TextureName); sp.SetWidth(width); sp.SetHeight(height); sp.SetPosition(X, Y); Sprites.Add(sp); sp = new Sprite(); sp.Texture = texturemanager.Get(TextureName); sp.SetWidth(width); sp.SetHeight(height); sp.SetPosition(X, Y); Sprites.Add(sp); }
public UIModDownloadItem(string displayname, string name, string version, string author, string modreferences, ModSide modside, string download, int downloads, int hot, string timeStamp, bool update, bool updateIsDowngrade, bool exists) { this.displayname = displayname; this.mod = name; this.version = version; this.author = author; this.modreferences = modreferences; this.modside = modside; this.download = download; this.downloads = downloads; this.hot = hot; this.timeStamp = timeStamp; this.update = update; this.updateIsDowngrade = updateIsDowngrade; this.exists = exists; this.BorderColor = new Color(89, 116, 213) * 0.7f; this.dividerTexture = TextureManager.Load("Images/UI/Divider"); this.innerPanelTexture = TextureManager.Load("Images/UI/InnerPanelBackground"); this.Height.Set(90f, 0f); this.Width.Set(0f, 1f); base.SetPadding(6f); string text = displayname + " " + version; this.modName = new UIText(text, 1f, false); this.modName.Left.Set(10f, 0f); this.modName.Top.Set(5f, 0f); base.Append(this.modName); UITextPanel <string> button = new UITextPanel <string>("More info", 1f, false); button.Width.Set(100f, 0f); button.Height.Set(30f, 0f); button.Left.Set(5f, 0f); button.Top.Set(40f, 0f); button.PaddingTop -= 2f; button.PaddingBottom -= 2f; button.OnMouseOver += UICommon.FadedMouseOver; button.OnMouseOut += UICommon.FadedMouseOut; button.OnClick += RequestMoreinfo; base.Append(button); if (update || !exists) { updateButton = new UITextPanel <string>(this.update ? (updateIsDowngrade ? "Downgrade" : "Update") : "Download", 1f, false); updateButton.CopyStyle(button); updateButton.Width.Set(200f, 0f); updateButton.Left.Set(button.Width.Pixels + button.Left.Pixels * 2f + 5f, 0f); updateButton.OnMouseOver += UICommon.FadedMouseOver; updateButton.OnMouseOut += UICommon.FadedMouseOut; updateButton.OnClick += this.DownloadMod; base.Append(updateButton); } if (modreferences.Length > 0) { UIHoverImage modReferenceIcon = new UIHoverImage(Main.quicksIconTexture, "This mod depends on: " + modreferences); modReferenceIcon.Left.Set(-135f, 1f); modReferenceIcon.Top.Set(50f, 0f); modReferenceIcon.OnClick += (s, e) => { UIModDownloadItem modListItem = (UIModDownloadItem)e.Parent; Interface.modBrowser.SpecialModPackFilter = modListItem.modreferences.Split(',').ToList(); Interface.modBrowser.SpecialModPackFilterTitle = "Dependencies"; // Toolong of \n" + modListItem.modName.Text; Interface.modBrowser.filterTextBox.currentString = ""; Interface.modBrowser.SortList(); Main.PlaySound(SoundID.MenuOpen); }; Append(modReferenceIcon); } base.OnDoubleClick += RequestMoreinfo; }
public static void Draw(int fps) { //draw menus on top //if (ShowTitle) { // Graphics.TextureManager.TextureProgram.SetModelView(Matrix4.Identity); // Graphics.TextureManager.TextureProgram.LeftMultModelView( // Matrix4.CreateTranslation(TextureManager.SCREEN_WIDTH / 2 - TextureManager.Title.ImageWidth / 2, // TextureManager.SCREEN_HEIGHT / 2 - TextureManager.Title.ImageHeight / 2, 1)); // Graphics.TextureManager.TextureProgram.UpdateModelView(); // Graphics.TextureManager.Title.Render(null); // Graphics.TextureManager.TextureProgram.SetModelView(Matrix4.Identity); // Gameplay.MenuManager.DrawMenus(); //} float scale = GetZoomScale(Zoom); Loc2D camCenter = new Loc2D(FocusedCharacter.CharLoc.X * TextureManager.TILE_SIZE + TextureManager.TILE_SIZE / 2, FocusedCharacter.CharLoc.Y * TextureManager.TILE_SIZE + TextureManager.TILE_SIZE / 2); camCenter = camCenter + CamOffset; Loc2D camStart = new Loc2D((int)(camCenter.X - TextureManager.SCREEN_WIDTH / scale / 2), (int)(camCenter.Y - TextureManager.SCREEN_HEIGHT / scale / 2)); Loc2D camEnd = new Loc2D((int)(camCenter.X + TextureManager.SCREEN_WIDTH / scale / 2), (int)(camCenter.Y + TextureManager.SCREEN_HEIGHT / scale / 2)); Loc2D camStartTile = new Loc2D(camStart.X / TextureManager.TILE_SIZE - 1, camStart.Y / TextureManager.TILE_SIZE - 1); Loc2D camEndTile = new Loc2D(camEnd.X / TextureManager.TILE_SIZE + 1, camEnd.Y / TextureManager.TILE_SIZE + 1); //TextureManager.TextureProgram.SetModelView(Matrix4.CreateTranslation(TextureManager.SCREEN_WIDTH / 2, TextureManager.SCREEN_HEIGHT / 2, 0)); //TextureManager.TextureProgram.SetModelView(Matrix4.CreateTranslation(-camCenter.X * scale, -camCenter.Y * scale, 0)); TextureManager.TextureProgram.SetModelView(Matrix4.CreateTranslation(-camCenter.X * scale + TextureManager.SCREEN_WIDTH / 2, -camCenter.Y * scale + TextureManager.SCREEN_HEIGHT / 2, 0)); TextureManager.TextureProgram.LeftMultModelView(Matrix4.CreateScale(scale)); //draw the background TextureManager.TextureProgram.PushModelView(); TextureManager.TextureProgram.SetTextureColor(new Color4(128, 128, 128, 255)); TextureManager.TextureProgram.LeftMultModelView(Matrix4.CreateScale(Math.Min(Map.Width, camEndTile.X) * TextureManager.TILE_SIZE, Math.Min(Map.Height, camEndTile.Y) * TextureManager.TILE_SIZE, 1)); TextureManager.TextureProgram.UpdateModelView(); TextureManager.BlankTexture.Render(null); TextureManager.TextureProgram.SetTextureColor(Color4.White); TextureManager.TextureProgram.PopModelView(); for (int j = camStartTile.Y; j <= camEndTile.Y; j++) { for (int i = camStartTile.X; i <= camEndTile.X; i++) { //set tile sprite position if (i < 0 || j < 0 || i >= Map.Width || j >= Map.Height) { } else { Map.DrawGround(i * TextureManager.TILE_SIZE, j * TextureManager.TILE_SIZE, new Loc2D(i, j)); if (Turn) { TextureManager.GetTile(1, new Loc2D(1, 0)).Render(null); } } } } //draw items foreach (ItemAnim item in Items) { if (!item.ActionDone && IsSpriteInView(camStart, camEnd, item)) { item.Draw(); } } //draw effects laid on ground List <ISprite> sortedSprites = new List <ISprite>(); foreach (ISprite effect in Effects[EffectPriority.Ground]) { if (IsSpriteInView(camStart, camEnd, effect)) { AddInOrder(sortedSprites, effect); } } int charIndex = 0; while (charIndex < sortedSprites.Count) { sortedSprites[charIndex].Draw(); charIndex++; } //draw effects in object space sortedSprites = new List <ISprite>(); //get all back effects, see if they're in the screen, and put them in the list, sorted foreach (ISprite effect in Effects[EffectPriority.Back]) { if (IsSpriteInView(camStart, camEnd, effect)) { AddInOrder(sortedSprites, effect); } } if (ShowSprites) { //check if player is in the screen, put in list foreach (PlayerSprite player in Players) { if (!player.Dead && IsSpriteInView(camStart, camEnd, player)) { AddInOrder(sortedSprites, player); } } //get all enemies, see if they're in the screen, and put them in the list, sorted foreach (NpcSprite npc in Npcs) { if (!npc.Dead && IsSpriteInView(camStart, camEnd, npc)) { AddInOrder(sortedSprites, npc); } } } //get all effects, see if they're in the screen, and put them in the list, sorted foreach (ISprite effect in Effects[EffectPriority.None]) { if (IsSpriteInView(camStart, camEnd, effect)) { AddInOrder(sortedSprites, effect); } } //draw object charIndex = 0; for (int j = camStartTile.Y; j <= camEndTile.Y; j++) { //before drawing objects, draw all active effects behind objects for (int i = camStartTile.X; i <= camEndTile.X; i++) { //set tile sprite position if (i < 0 || j < 0 || i >= Map.Width || j >= Map.Height) { } else { Map.DrawPropBack(i * TextureManager.TILE_SIZE, j * TextureManager.TILE_SIZE, new Loc2D(i, j)); } } //after drawing objects of the row, draw characters whose locations are of between that row(inc) to the next(exc) while (charIndex < sortedSprites.Count) { int charY = sortedSprites[charIndex].MapLoc.Y; if (charY == j * TextureManager.TILE_SIZE) { sortedSprites[charIndex].Draw(); charIndex++; } else { break; } } for (int i = camStartTile.X; i <= camEndTile.X; i++) { //set tile sprite position if (i < 0 || j < 0 || i >= Map.Width || j >= Map.Height) { } else { Map.DrawPropFront(i * TextureManager.TILE_SIZE, j * TextureManager.TILE_SIZE, new Loc2D(i, j)); } } //after drawing objects of the row, draw characters whose locations are of between that row(inc) to the next(exc) while (charIndex < sortedSprites.Count) { int charY = sortedSprites[charIndex].MapLoc.Y; if (charY < (j + 1) * TextureManager.TILE_SIZE) { sortedSprites[charIndex].Draw(); charIndex++; } else { break; } } } //draw remaining sprites while (charIndex < sortedSprites.Count) { sortedSprites[charIndex].Draw(); charIndex++; } //draw effects in top sortedSprites = new List <ISprite>(); foreach (ISprite effect in Effects[EffectPriority.Top]) { if (IsSpriteInView(camStart, camEnd, effect)) { AddInOrder(sortedSprites, effect); } } charIndex = 0; while (charIndex < sortedSprites.Count) { sortedSprites[charIndex].Draw(); charIndex++; } //draw foreground for (int j = camStartTile.Y; j <= camEndTile.Y; j++) { for (int i = camStartTile.X; i <= camEndTile.X; i++) { //set tile sprite position if (i < 0 || j < 0 || i >= Map.Width || j >= Map.Height) { } else { Map.DrawFringe(i * TextureManager.TILE_SIZE, j * TextureManager.TILE_SIZE, new Loc2D(i, j)); if (ShowGrid) { TextureManager.TextureProgram.PushModelView(); TextureManager.TextureProgram.LeftMultModelView(Matrix4.CreateTranslation(i * TextureManager.TILE_SIZE, j * TextureManager.TILE_SIZE, 0)); TextureManager.TextureProgram.UpdateModelView(); TextureManager.GetTile(10, new Loc2D()).Render(null); TextureManager.TextureProgram.PopModelView(); } } } } //draw effects in foreground sortedSprites = new List <ISprite>(); foreach (ISprite effect in Effects[EffectPriority.Overlay]) { if (IsSpriteInView(camStart, camEnd, effect)) { AddInOrder(sortedSprites, effect); } } charIndex = 0; while (charIndex < sortedSprites.Count) { sortedSprites[charIndex].Draw(); charIndex++; } TextureManager.TextureProgram.SetModelView(Matrix4.Identity); Gameplay.MenuManager.DrawMenus(); //Moves TextureManager.TextureProgram.SetModelView(Matrix4.Identity); if (Spell) { string[] keys = new string[4] { "S", "D", "X", "C" }; TextureManager.TextureProgram.LeftMultModelView(Matrix4.CreateTranslation(-240, 32, 0)); for (int i = 0; i < Gameplay.Processor.MAX_MOVE_SLOTS; i++) { TextureManager.TextureProgram.LeftMultModelView(Matrix4.CreateTranslation(0, 64, 0)); TextureManager.TextureProgram.UpdateModelView(); if (CurrentCharMoves[i] >= 0) { Data.MoveEntry moveEntry = Data.GameData.MoveDex[CurrentCharMoves[i]]; TextureManager.SingleFont.RenderText(244, 20, keys[i] + ": (" + moveEntry.PP + "PP) " + moveEntry.Name, null, AtlasSheet.SpriteVOrigin.Top, AtlasSheet.SpriteHOrigin.Left, 0, Color4.White); } else { TextureManager.SingleFont.RenderText(244, 20, keys[i] + ": Empty", null, AtlasSheet.SpriteVOrigin.Top, AtlasSheet.SpriteHOrigin.Left, 0, Color4.White); } } } //draw transitions if (CurrentFade == FadeType.FadeIn) { TextureManager.TextureProgram.SetModelView(Matrix4.Identity); TextureManager.TextureProgram.SetTextureColor(new Color4(0, 0, 0, (byte)(FadeTime.Ticks * 255 / TOTAL_FADE_TIME.Ticks))); TextureManager.TextureProgram.LeftMultModelView(Matrix4.CreateScale(TextureManager.SCREEN_WIDTH, TextureManager.SCREEN_HEIGHT, 1)); TextureManager.TextureProgram.UpdateModelView(); TextureManager.BlankTexture.Render(null); TextureManager.TextureProgram.SetTextureColor(Color4.White); } else if (CurrentFade == FadeType.FadeOut) { TextureManager.TextureProgram.SetModelView(Matrix4.Identity); TextureManager.TextureProgram.SetTextureColor(new Color4(0, 0, 0, (byte)(255 - FadeTime.Ticks * 255 / TOTAL_FADE_TIME.Ticks))); TextureManager.TextureProgram.LeftMultModelView(Matrix4.CreateScale(TextureManager.SCREEN_WIDTH, TextureManager.SCREEN_HEIGHT, 1)); TextureManager.TextureProgram.UpdateModelView(); TextureManager.BlankTexture.Render(null); TextureManager.TextureProgram.SetTextureColor(Color4.White); } if (ShowDebug) { DrawDebug(fps); } }
public void LoadTextures() { Input.DirectKeyCode += KeyCode; TextureManager.RegisterTextures(textures); }