Permalink
Browse files

version 1.5 release

search again with F3 until end of data
animated welcome screen shader
  • Loading branch information...
movAX13h committed May 21, 2017
1 parent c419f5c commit 65d9faa14df507419ad522b4ba8c0dba56a2dd70
Showing with 151 additions and 21 deletions.
  1. +6 −0 Binmap/Content/Content.mgcb
  2. +72 −0 Binmap/Content/Shaders/Intro.fx
  3. +56 −6 Binmap/Controls/BinList.cs
  4. +5 −2 Binmap/Main.cs
  5. +4 −9 Binmap/Screens/Layouter.cs
  6. +8 −4 README.md
@@ -37,3 +37,9 @@
/processorParam:TextureFormat=Color
/build:Logo.png
#begin Shaders/Intro.fx
/importer:EffectImporter
/processor:EffectProcessor
/processorParam:DebugMode=Auto
/build:Shaders/Intro.fx
@@ -0,0 +1,72 @@
#if OPENGL
#define SV_POSITION POSITION
#define VS_SHADERMODEL vs_3_0
#define PS_SHADERMODEL ps_3_0
#else
#define VS_SHADERMODEL vs_4_0_level_9_3
#define PS_SHADERMODEL ps_4_0_level_9_3
#endif
float Time;
float2 Size;
Texture2D SpriteTexture;
sampler2D SpriteTextureSampler = sampler_state
{
Texture = <SpriteTexture>;
};
struct VertexShaderOutput
{
float4 Position : SV_POSITION;
float4 Color : COLOR0;
float2 TextureCoordinates : TEXCOORD0;
};
float rand(float x) { return frac(sin(x) * 4358.5453123); }
float rand(float2 co) { return frac(sin(dot(co.xy, float2(12.9898, 78.233))) * 43758.5357); }
float invader(float2 p, float n)
{
p.x = abs(p.x);
p.y = floor(p.y - 5.0);
return step(p.x, 2.0) * step(1.0, floor((n / (exp2(floor(p.x - 3.0*p.y))) % 2.0)));
}
float ring(float2 uv, float rnd)
{
float t = 0.6*(Time + 0.2*rnd);
float i = floor(t / 2.0);
float2 pos = 2.0*float2(rand(i*0.123), rand(i*2.371)) - 1.0;
return lerp(0.2, 0.0, abs(length(uv - pos) - (t % 2.0)));
}
float3 color = float3(0.6, 0.1, 0.3); // red
float4 MainPS(VertexShaderOutput input) : COLOR
{
//float4 col = 0.0 * tex2D(SpriteTextureSampler,input.TextureCoordinates) * input.Color;
float2 p = input.TextureCoordinates * Size;
float2 uv = p / Size - 0.5;
p.y += 40.0*Time;
float r = rand(floor(p / 8.0));
float2 ip = (p % 8.0) - 4.0;
float a = //lerp(0.1, 0.8, length(uv)) +
invader(ip, 809999.0*r) * (0.06 + 0.3*ring(uv, r) + max(0.0, 0.2*sin(10.0*r*Time)));
return input.Color + 0.5*float4(a, a, a, 1.0);
}
technique SpriteDrawing
{
pass P0
{
PixelShader = compile PS_SHADERMODEL MainPS();
}
};
View
@@ -62,6 +62,11 @@ public Point ItemSpace
private Action<BinListItem> itemSelectedCallback;
private BinListItem overItem = null;
private float currentTime = 0;
private bool f3KeyWasDown = false;
private byte[] lastSearchQuery;
private int lastSearchResult = 0;
public BinList(int x, int y, int w, int h, Action<BinListItem> itemSelectedCallback, Action<string, float> statusCallback) : base(x, y, w, h, Main.BorderColor)
{
this.statusCallback = statusCallback;
@@ -279,7 +284,20 @@ public bool ProcessKey(Keys key)
public override void Update(float time, float dTime)
{
base.Update(time, dTime);
currentTime = time;
// continue search (do this here so it does not require control focus)
if (Main.KeyboardState.IsKeyDown(Keys.F3))
{
f3KeyWasDown = true;
}
else
{
if (f3KeyWasDown && lastSearchQuery != null) Search(lastSearchQuery, lastSearchResult + 1);
f3KeyWasDown = false;
}
// clear selection
if (MouseIsOver && Main.MouseState.RightButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed)
{
@@ -291,12 +309,30 @@ public override void Update(float time, float dTime)
public override void CustomDraw(SpriteBatch spriteBatch)
{
Rectangle rect = WorldTransform;
Rectangle innerRect = new Rectangle(rect.X + 1, rect.Y + 1, rect.Width - 2, rect.Height - 2);
// background
spriteBatch.Draw(Main.WhiteTexture, new Rectangle(rect.X + 1, rect.Y + 1, rect.Width - 2, rect.Height - 2), Main.PanelColor);
if (bins.Count > 0)
{
// background
spriteBatch.Draw(Main.WhiteTexture, innerRect, Main.PanelColor);
// vertical separator line for comments column
if (bins.Count > 0) spriteBatch.Draw(Main.WhiteTexture, new Rectangle(rect.X + rect.Width - commentColumnWidth, rect.Y + 2, 1, rect.Height - 4), Main.BorderColor);
// vertical separator line for comments column
spriteBatch.Draw(Main.WhiteTexture, new Rectangle(rect.X + rect.Width - commentColumnWidth, rect.Y + 2, 1, rect.Height - 4), Main.BorderColor);
}
else
{
// special shader for background when empty
spriteBatch.End();
Main.IntroShader.Parameters["Size"].SetValue(new Vector2(innerRect.Width, innerRect.Height));
Main.IntroShader.Parameters["Time"].SetValue(currentTime);
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, Main.IntroShader);
spriteBatch.Draw(Main.WhiteTexture, innerRect, Main.PanelColor);
spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp);
return;
}
}
public override void Draw(SpriteBatch spriteBatch)
@@ -370,19 +406,31 @@ public void AddScrollbarMark(int pos, Color color)
public int Search(byte[] query, int offset = 0)
{
lastSearchQuery = query;
int end = bins.Count - query.Length;
int num = 0;
string text = "";
foreach (byte b in query) text += b.ToString("X2") + " ";
for (int i = offset; i < end; i++)
{
if (bins[i].Value == query[num])
{
num++;
if (num == query.Length) return i - query.Length + 1;
if (num == query.Length)
{
lastSearchResult = i - query.Length + 1;
ScrollTo(lastSearchResult);
return lastSearchResult;
}
}
else num = 0;
}
if (offset > 0) statusCallback("Search reached the end.", 1);
else statusCallback("No match found for query '" + text + "'.", 2);
return -1;
}
@@ -415,6 +463,8 @@ public void AddItem(Bin item)
public void Clear()
{
bins.Clear();
lastSearchQuery = null;
lastSearchResult = 0;
dirty = true;
deselectAll();
scrollbar.ClearMarks();
View
@@ -22,6 +22,7 @@ public class Main : Game
public static SpriteFont FontL;
public static Texture2D Logo;
public static Effect IntroShader;
public static Color BackgroundColor = Color.FromNonPremultiplied(45, 45, 48, 255);
public static Color PanelColor = Color.FromNonPremultiplied(30, 30, 30, 255);
@@ -45,7 +46,7 @@ public static void SetFocus(IInput control)
if (focusedControl != null) focusedControl.Focused = true;
}
public static string Version = "1.4";
public static string Version = "1.5";
Keys[] prevPressed;
GraphicsDeviceManager graphics;
@@ -88,7 +89,7 @@ protected override void LoadContent()
{
spriteBatch = new SpriteBatch(GraphicsDevice);
WhiteTexture = new Texture2D(GraphicsDevice, 10, 10, false, SurfaceFormat.Color);
FontS = Content.Load<SpriteFont>("Fonts/Font1");
FontS.LineSpacing = 12;
@@ -97,6 +98,8 @@ protected override void LoadContent()
Logo = Content.Load<Texture2D>("Logo");
IntroShader = Content.Load<Effect>("Shaders/Intro");
DefaultFont = FontL;
Color[] colorData = new Color[100];
View
@@ -37,7 +37,7 @@ class Layouter : Container
private bool statusFadeOut = true;
private float statusTime = 0;
private string usageText = "LMB: select/deselect, Shift+LMB: range selection, RMB: clear selection, ENTER: line break, BACKSPACE: remove line break";
private string usageText = "LMB: select/deselect, SHIFT+LMB: range select, RMB: clear selection, ENTER/BKSPC: add/remove line break, F3: search again";
private string startText = "DROP FILE TO START";
public string DataFilename { get; private set; } = string.Empty;
@@ -425,13 +425,13 @@ public override void Draw(SpriteBatch spriteBatch)
{
Point center = new Point(list.Transform.X + list.Transform.Width / 2, list.Transform.Y + list.Transform.Height / 2);
color = Color.FromNonPremultiplied(255, 255, 255, 40);
color = Color.FromNonPremultiplied(255, 255, 255, 140);
spriteBatch.Draw(Main.Logo, new Rectangle(center.X - Main.Logo.Width, center.Y - Main.Logo.Height * 2 + 50, Main.Logo.Width * 2, Main.Logo.Height * 2), color);
Vector2 size = Main.FontL.MeasureString(startText);
spriteBatch.DrawString(Main.FontL, startText,
new Vector2((float)Math.Floor(center.X - size.X / 2f), (float)Math.Floor(center.Y - size.Y / 2f) + 70),
Main.BorderColor);
Main.TrackColor);
}
// write button position and visibility
@@ -558,12 +558,7 @@ private void searchChanged(IInput input)
private void searchCommitted(IInput input)
{
byte[] query = getSearchQuery();
if (query != null)
{
int i = list.Search(query);
if (i >= 0) list.ScrollTo(i);
else showStatus("No match found for query '" + searchInput.Text + "'.", 2);
}
if (query != null) list.Search(query);
}
private void valueChanged(IInput input)
View
@@ -1,14 +1,15 @@
# ![Binmap Logo](https://cloud.githubusercontent.com/assets/1974959/25785795/2718aaf2-3389-11e7-9078-fbf5b20801bf.png) Binmap
A tool that helps to analyse and document binary data file formats. It also allows to edit values and write back changes.
A tool that helps to analyse and document binary data files/formats. It can also be used to edit values and write back changes, just like a regular hex-editor but does not allow to insert or delete bytes.
All UI controls of this application are custom-made for fast rendering and style.
## Screenshots
start screen:
![Binmap start screen](https://cloud.githubusercontent.com/assets/1974959/25785729/f80b0ab2-3387-11e7-8a06-2a2b3fe750a1.png)
![Binmap start screen](https://cloud.githubusercontent.com/assets/1974959/26288049/e2834f54-3e88-11e7-9d82-d5850e95cee0.png)
data loaded, unformatted:
data loaded, unformatted; all bytes are formatted in hex by default:
![Binmap unformatted data](https://cloud.githubusercontent.com/assets/1974959/25785754/6fac491e-3388-11e7-9d53-cf7eb44e84da.png)
@@ -35,12 +36,15 @@ The font in use is called [Pixel Operator](http://www.dafont.com/de/pixel-operat
If you are interested in a release download, here is the latest public release (might be some subversions behind): [Binmap Release](https://github.com/movAX13h/Binmap/releases/latest)
### Todo
- continue search with F3
- TextInput text range selection (mouse and keyboard), handle longer texts
- Scrollbar track click
- view for multiple bytes combined as int, float, double, ...
### Changelog
- v1.5 - 2017-05-22
- F3 to repeat search (scrolls to next result till end of file is reached)
- welcome screen shader
- v1.4 - 2017-05-16
- added goto address panel (scrolls list to address) with format switch (hex/dec)
- added search panel with format switch (hex/dec)

0 comments on commit 65d9faa

Please sign in to comment.