Example #1
0
 internal static void SaveUserDataLocal()
 {
     userdata.UpdateRawData();
     userdata.EncryptStrings();
     DataHandler.SaveData <UserData>(userdata, datafile);
 }
Example #2
0
 internal override void Draw(SpriteBatch batch, Camera2D cam = null)
 {
     base.Draw(batch, cam);
     if (!visible)
     {
         return;
     }
     // Draw overlay
     if (DataHandler.isValid(overlay))
     {
         RectangleF rect = LocalBoundingBox.Inflate(-Width * border, -Height * border);
         if (cam == null)
         {
             batch.Draw(DataHandler.getTexture(overlay.RefKey) /*Texture2D from file*/, cam == null ? rect.ToRectangle() : cam.Transform(rect).ToRectangle() /*on-screen box*/, DataHandler.getTextureSource(overlay) /*Rectange on the sheet*/, Color.White /*white=no tint*/);
         }
         else if (cam.isInsideView(rect))
         {
             RectangleF nocrop;
             RectangleF cropped = cam.TransformWithCropping(rect, out nocrop);
             RectangleF source  = DataHandler.getTextureSource(overlay);
             source = source.Mask(nocrop, cropped);
             batch.Draw(DataHandler.getTexture(overlay.RefKey) /*Texture2D from file*/, cropped.Offset(parent.GlobalPosition).ToRectangle() /*on-screen box*/, source.ToRectangle() /*Rectange on the sheet*/, Color.White /*white=no tint*/);
         }
     }
     // Siblings
     foreach (UIVisibleObject obj in siblings.Where(t => t is UIVisibleObject))
     {
         obj.Draw(batch, cam);
     }
     // Children
     foreach (UIVisibleObject obj in children.Where(t => t is UIVisibleObject))
     {
         obj.Draw(batch, cam);
     }
     // Draw text
     if (text != "" && text != "\0")
     {
         Vector2 tsize = font.MeasureString(text);
         if (cam == null || cam.isInsideView(LocalCenter))
         {
             batch.DrawString(font, text, GlobalCenter - tsize / 2 - cam.ActualView.Location, color);
         }
     }
 }
Example #3
0
 internal static void SaveSettings()
 {
     DataHandler.SaveData <Settings>(settings, settingsfile);
 }
Example #4
0
 internal virtual void Draw(SpriteBatch batch, Camera2D cam = null) // You don't need a camera, draw ontop of the stage
 {
     if (!visible || sprite == null)
     {
         return;
     }
     if (cam == null)
     {
         batch.Draw(DataHandler.getTexture(sprite[state].RefKey) /*Texture2D from file*/, BoundingBox.ToRectangle() /*on-screen box*/, DataHandler.getTextureSource(sprite[state]) /*Rectange on the sheet*/, Color.White /*white=no tint*/);
     }
     else
     {
         if (cam.isInsideView(LocalBoundingBox))
         {
             RectangleF nocrop;
             RectangleF cropped = cam.TransformWithCropping(LocalBoundingBox, out nocrop);
             RectangleF source  = DataHandler.getTextureSource(sprite[state]);
             // rect is an intersection of nocrop, thus contained by it
             source = source.Mask(nocrop, cropped);
             batch.Draw(DataHandler.getTexture(sprite[state].RefKey) /*Texture2D from file*/,
                        cropped.Offset(parent.GlobalPosition).ToRectangle() /*on-screen box*/,
                        source.ToRectangle() /*Rectange on the sheet*/,
                        Color.White /*white=no tint*/);
         }
     }
 }