1414using System . Windows . Forms ;
1515using Ultima ;
1616using UoFiddler . Controls . Classes ;
17- using UoFiddler . Controls . UserControls ;
1817
1918namespace UoFiddler . Controls . Forms
2019{
2120 public partial class HueEditForm : Form
2221 {
23- //private readonly HuesControl _refMarker; // TODO: unused?
2422 private readonly Hue _hue ;
2523 private readonly short [ ] _colors ;
2624 private int _selected ;
@@ -52,12 +50,11 @@ private int SecondSelected
5250 }
5351 }
5452
55- public HueEditForm ( int index , HuesControl mRefMarker )
53+ public HueEditForm ( int index )
5654 {
5755 InitializeComponent ( ) ;
5856 Icon = Options . GetFiddlerIcon ( ) ;
5957
60- //_refMarker = mRefMarker;
6158 Text = $ "HueEdit { index } / 0x{ index : X} ";
6259
6360 _hue = Hues . GetHue ( index ) ;
@@ -177,7 +174,9 @@ private void OnClickSpread(object sender, EventArgs e)
177174
178175 _colors [ start + i ] = Hues . ColorToHue ( newC ) ;
179176 }
177+
180178 pictureBox . Invalidate ( ) ;
179+
181180 RefreshPreview ( ) ;
182181 }
183182
@@ -190,6 +189,7 @@ private void OnClickEpxGradient(object sender, EventArgs e)
190189
191190 int start = Math . Min ( SecondSelected , Selected ) ;
192191 int end = Math . Max ( SecondSelected , Selected ) ;
192+
193193 int diff = end - start ;
194194 if ( diff <= 1 )
195195 {
@@ -198,9 +198,11 @@ private void OnClickEpxGradient(object sender, EventArgs e)
198198
199199 Color startColor = Hues . HueToColor ( _colors [ start ] ) ;
200200 Color endColor = Hues . HueToColor ( _colors [ end ] ) ;
201+
201202 double redDiv = Math . Log ( Math . Abs ( endColor . R - startColor . R ) , Math . E ) / Math . Log ( diff , Math . E ) ;
202203 double greenDiv = Math . Log ( Math . Abs ( endColor . G - startColor . G ) , Math . E ) / Math . Log ( diff , Math . E ) ;
203204 double blueDiv = Math . Log ( Math . Abs ( endColor . B - startColor . B ) , Math . E ) / Math . Log ( diff , Math . E ) ;
205+
204206 int redFac = 1 ;
205207 if ( endColor . R - startColor . R < 0 )
206208 {
@@ -225,9 +227,12 @@ private void OnClickEpxGradient(object sender, EventArgs e)
225227 ( int ) ( startColor . R + ( redFac * Math . Pow ( i , redDiv ) ) ) ,
226228 ( int ) ( startColor . G + ( greenFac * Math . Pow ( i , greenDiv ) ) ) ,
227229 ( int ) ( startColor . B + ( blueFac * Math . Pow ( i , blueDiv ) ) ) ) ;
230+
228231 _colors [ start + i ] = Hues . ColorToHue ( newColor ) ;
229232 }
233+
230234 pictureBox . Invalidate ( ) ;
235+
231236 RefreshPreview ( ) ;
232237 }
233238
@@ -240,6 +245,7 @@ private void OnClickInverse(object sender, EventArgs e)
240245
241246 int start = Math . Min ( SecondSelected , Selected ) ;
242247 int end = Math . Max ( SecondSelected , Selected ) ;
248+
243249 while ( start < end )
244250 {
245251 short temp = _colors [ start ] ;
@@ -248,7 +254,9 @@ private void OnClickInverse(object sender, EventArgs e)
248254 ++ start ;
249255 -- end ;
250256 }
257+
251258 Selected = _selected ;
259+
252260 RefreshPreview ( ) ;
253261 }
254262
@@ -261,6 +269,7 @@ private void OnClickModifyRange(object sender, EventArgs e)
261269
262270 int start = Math . Min ( SecondSelected , Selected ) ;
263271 int end = Math . Max ( SecondSelected , Selected ) ;
272+
264273 for ( int i = start ; i <= end ; ++ i )
265274 {
266275 Color color = Hues . HueToColor ( _colors [ i ] ) ;
@@ -273,7 +282,9 @@ private void OnClickModifyRange(object sender, EventArgs e)
273282 Math . Max ( 0 , Math . Min ( 255 , b ) ) ) ;
274283 _colors [ i ] = Hues . ColorToHue ( newColor ) ;
275284 }
285+
276286 Selected = _selected ;
287+
277288 RefreshPreview ( ) ;
278289 }
279290
@@ -307,7 +318,9 @@ private void OnKeyDownArt(object sender, KeyEventArgs e)
307318 }
308319
309320 contextMenuStrip1 . Close ( ) ;
321+
310322 _preview = Art . GetStatic ( index ) ;
323+
311324 RefreshPreview ( ) ;
312325 }
313326
@@ -336,14 +349,18 @@ private void OnKeyDownAnim(object sender, KeyEventArgs e)
336349 }
337350
338351 contextMenuStrip1 . Close ( ) ;
352+
339353 int hueRef = 0 ;
354+
340355 AnimationFrame [ ] frames = Animations . GetAnimation ( index , 0 , 1 , ref hueRef , false , true ) ;
356+
341357 if ( frames == null )
342358 {
343359 return ;
344360 }
345361
346362 _preview = frames [ 0 ] . Bitmap ;
363+
347364 RefreshPreview ( ) ;
348365 }
349366
@@ -377,7 +394,9 @@ private void OnKeyDownGump(object sender, KeyEventArgs e)
377394 }
378395
379396 contextMenuStrip1 . Close ( ) ;
397+
380398 _preview = Gumps . GetGump ( index ) ;
399+
381400 RefreshPreview ( ) ;
382401 }
383402
@@ -399,13 +418,15 @@ private void RefreshPreview()
399418 g . DrawImage ( bmp , x , y ) ;
400419 }
401420 }
421+
402422 pictureBoxPreview . Invalidate ( ) ;
403423 }
404424
405425 private void SetColorButton_Click ( object sender , EventArgs e )
406426 {
407- _colors [ _selected ] = Hues . ColorToHue ( Color . FromArgb ( ( int ) numericUpDownR . Value , ( int ) numericUpDownG . Value ,
408- ( int ) numericUpDownB . Value ) ) ;
427+ _colors [ _selected ] = Hues . ColorToHue ( Color . FromArgb ( ( int ) numericUpDownR . Value ,
428+ ( int ) numericUpDownG . Value ,
429+ ( int ) numericUpDownB . Value ) ) ;
409430
410431 pictureBox . Invalidate ( ) ;
411432 pictureBoxIndex . Invalidate ( ) ;
0 commit comments