Skip to content

Commit

Permalink
Made fantasy intro possible on full screen
Browse files Browse the repository at this point in the history
  • Loading branch information
Pyrdacor committed Mar 6, 2023
1 parent 2335c15 commit 7d27079
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@ obj
/Ambermoon.net/Saves
/Ambermoon.net/Screenshots
/Ambermoon.net/music
*.cache
/Ambermoon.net/error.txt
/Ambermoon.net/diffs.dat
/Ambermoon.net/ambermoon.cfg
/publish-win64
/ambermoon.cfg
45 changes: 44 additions & 1 deletion Ambermoon.net/FantasyIntro.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Ambermoon.Render;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Ambermoon
Expand All @@ -15,6 +16,8 @@ internal class FantasyIntro
readonly IRenderLayer renderLayer;
readonly IRenderLayer colorLayer;
readonly Queue<FantasyIntroAction> actions = null;
readonly ILayerSprite backgroundLeftBorder;
readonly ILayerSprite backgroundRightBorder;
readonly ILayerSprite background;
readonly ILayerSprite fairy;
readonly ILayerSprite writing;
Expand All @@ -30,13 +33,32 @@ internal class FantasyIntro
long lastFrame = -1;
bool playFairyAnimation = false;
uint fairyAnimationIndex = 0;
static uint borderTextureIndexOffset = 0;

static void EnsureTextures(IRenderView renderView, IFantasyIntroData fantasyIntroData)
{
if (textureAtlas == null)
{
TextureAtlasManager.Instance.AddFromGraphics(Layer.FantasyIntroGraphics,
fantasyIntroData.Graphics.ToDictionary(g => (uint)g.Key, g => g.Value));
var borders256 = new DataReader(Resources.Borders256);
borderTextureIndexOffset = (uint)fantasyIntroData.Graphics.Keys.Max() + 1;
var borderGraphicInfo = new GraphicInfo
{
Width = 45,
Height = 256,
GraphicFormat = GraphicFormat.Palette5Bit,
Alpha = false
};
var graphicReader = new GraphicReader();
Graphic LoadBorder()
{
var border = new Graphic();
graphicReader.ReadGraphic(border, borders256, borderGraphicInfo);
return border;
}
TextureAtlasManager.Instance.AddFromGraphics(Layer.FantasyIntroGraphics,
Enumerable.Range(0, 2).ToDictionary(i => (uint)(borderTextureIndexOffset + i), _ => LoadBorder()));
textureAtlas = TextureAtlasManager.Instance.GetOrCreate(Layer.FantasyIntroGraphics);
renderView.GetLayer(Layer.FantasyIntroGraphics).Texture = textureAtlas.Texture;
}
Expand All @@ -52,6 +74,24 @@ public FantasyIntro(IRenderView renderView, IFantasyIntroData fantasyIntroData,

EnsureTextures(renderView, fantasyIntroData);

backgroundLeftBorder = renderView.SpriteFactory.Create(45, 256, true, 1) as ILayerSprite;
backgroundLeftBorder.Layer = renderLayer;
backgroundLeftBorder.PaletteIndex = GetPaletteIndex(FantasyIntroGraphic.Background);
backgroundLeftBorder.TextureAtlasOffset = textureAtlas.GetOffset(borderTextureIndexOffset);
backgroundLeftBorder.X = -45;
backgroundLeftBorder.Y = 0;
backgroundLeftBorder.ClipArea = new Rect(-45, 0, 366, 256);
backgroundLeftBorder.Visible = false;

backgroundRightBorder = renderView.SpriteFactory.Create(45, 256, true, 1) as ILayerSprite;
backgroundRightBorder.Layer = renderLayer;
backgroundRightBorder.PaletteIndex = GetPaletteIndex(FantasyIntroGraphic.Background);
backgroundRightBorder.TextureAtlasOffset = textureAtlas.GetOffset(borderTextureIndexOffset + 1);
backgroundRightBorder.X = 320;
backgroundRightBorder.Y = 0;
backgroundRightBorder.ClipArea = new Rect(-45, 0, 366, 256);
backgroundRightBorder.Visible = false;

background = renderView.SpriteFactory.Create(320, 256, true, 1) as ILayerSprite;
background.Layer = renderLayer;
background.PaletteIndex = GetPaletteIndex(FantasyIntroGraphic.Background);
Expand Down Expand Up @@ -213,7 +253,8 @@ public void Update(double deltaTime)
if (time == 0)
{
Active = true;

backgroundLeftBorder.Visible = true;
backgroundRightBorder.Visible = true;
background.Visible = true;
}

Expand Down Expand Up @@ -328,6 +369,8 @@ public void Abort()
private void Destroy()
{
Active = false;
backgroundLeftBorder?.Delete();
backgroundRightBorder?.Delete();
background?.Delete();
fairy?.Delete();
writing?.Delete();
Expand Down
2 changes: 2 additions & 0 deletions Ambermoon.net/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Ambermoon.net/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@
<data name="advanced" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\advanced.pyr;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="borders256" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\borders256.pyr;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="IntroFont" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\IntroFont.dat;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
Expand Down
Binary file added Ambermoon.net/Resources/AppIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Ambermoon.net/Resources/borders256.pyr
Binary file not shown.
3 changes: 3 additions & 0 deletions NewVersion.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
git add -u
git commit -m "This is v%1"
git tag -a v%1 -m "Version %1"

0 comments on commit 7d27079

Please sign in to comment.