Skip to content

Commit

Permalink
Fixes before publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
Knightro63 committed Oct 9, 2023
1 parent f9e54bc commit e0481f3
Show file tree
Hide file tree
Showing 13 changed files with 107 additions and 73 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ analysis_benchmark.json
.packages
.pub-preload-cache/
.pub/
*.lock
build/
flutter_*.png
linked_*.ds
Expand Down
19 changes: 0 additions & 19 deletions ember.iml

This file was deleted.

37 changes: 18 additions & 19 deletions lib/imageEditor/object.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'dart:ui';
import 'package:flutter/material.dart' hide Image;
import 'package:vector_math/vector_math_64.dart' hide Triangle hide Colors;
import '../editors/editors.dart';

Expand Down Expand Up @@ -29,21 +28,21 @@ class Object {
late Vector3 position;
Vector3 _tempPosition = Vector3.zero();
late Size size;
Vector2 _from = Vector2(0,0);
Vector2 from = Vector2(0,0);

void updatePositionStart(Vector2 to){
_from.x = to.x;
_from.y = to.y;
from.x = to.x;
from.y = to.y;
}
void updatePosition(Vector2 to, [double sensitivity=1.0]){
final double x = (to.x - _from.x)/100*sensitivity;
final double y = (to.y - _from.y)/100*sensitivity;
final double x = (to.x - from.x)/100*sensitivity;
final double y = (to.y - from.y)/100*sensitivity;

position.x += x;
position.y -= y;

_from.x = to.x;
_from.y = to.y;
from.x = to.x;
from.y = to.y;
}
void move(int x, int y){
position.x = _tempPosition.x+x/100;
Expand All @@ -59,13 +58,13 @@ class Object {
size = Size(size.width+x,size.height+y);
}
void scaleMouse(Vector2 to, [double sensitivity=1.0]){
final double x = ((to.x - _from.x))*sensitivity;
final double y = ((to.y - _from.y))*sensitivity;
final double x = ((to.x - from.x))*sensitivity;
final double y = ((to.y - from.y))*sensitivity;

size = Size(size.width+x,size.height+y);

_from.x = to.x;
_from.y = to.y;
from.x = to.x;
from.y = to.y;
}
}
class SpriteImage{
Expand All @@ -86,24 +85,24 @@ class SpriteImage{
String name;
late Vector3 position;
Vector3 _tempPosition = Vector3.zero();
Vector2 _from = Vector2(0,0);
Vector2 from = Vector2(0,0);
Color color;

void updatePositionStart(Vector2 to){
_from.x = to.x;
_from.y = to.y;
from.x = to.x;
from.y = to.y;
}
void updatePosition(Vector2 to, [double sensitivity=1.0]){
final double x = ((to.x - _from.x))/100*sensitivity;
final double y = ((to.y - _from.y))/100*sensitivity;
final double x = ((to.x - from.x))/100*sensitivity;
final double y = ((to.y - from.y))/100*sensitivity;

position.x += x;
position.y -= y;

_tempPosition = position;

_from.x = to.x;
_from.y = to.y;
from.x = to.x;
from.y = to.y;
}
void move(int x, int y){
position.x = _tempPosition.x+x/100;
Expand Down
6 changes: 3 additions & 3 deletions lib/imageEditor/scene.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'dart:async';
import 'dart:io';
import 'dart:typed_data';
import 'dart:ui';
import 'package:ember/utils/logger.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart' hide Image;
import 'package:vector_math/vector_math_64.dart' hide Triangle, Vector4, Colors;
Expand Down Expand Up @@ -157,7 +157,7 @@ class ImageScene {
}
}
}
print(type == selectableType);
logger?.verbose(type == selectableType);
if(tapLocation != null && rect.contains(tapLocation!) && isDifferent && type == selectableType){
isClicked = true;
if(currentSize == null){
Expand Down Expand Up @@ -231,7 +231,7 @@ class ImageScene {
}
// Mark needs update texture
void updateTapLocation(Offset details) {
print(details);
logger?.verbose(details);
if(!isControlPressed){
objectTappedOn = [];
currentSize = null;
Expand Down
4 changes: 2 additions & 2 deletions lib/imageEditor/widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ class ImageEditor extends StatefulWidget {
final ImageScene scene;

@override
_ImageEditorState createState() => _ImageEditorState();
ImageEditorState createState() => ImageEditorState();
}

class _ImageEditorState extends State<ImageEditor> {
class ImageEditorState extends State<ImageEditor> {
late ImageScene scene;
Offset? _lastFocalPointZoom;
double? _lastZoom;
Expand Down
20 changes: 10 additions & 10 deletions lib/levelEditor/model/model_renderer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ class ModelRender extends LevelEditor{
final Float32List positionsZ = renderMesh.positionsZ;

final List<Vector3> vertices = o.mesh[mesh].vertices;
final List<Vector3> normals = o.mesh[mesh].normals;
//final List<Vector3> normals = o.mesh[mesh].normals;

final int vertexOffset = renderMesh.vertexCount;
final int vertexCount = vertices.length;
Expand All @@ -212,9 +212,9 @@ class ModelRender extends LevelEditor{

//color information
final Int32List renderColors = renderMesh.colors;
final Matrix4 normalTransform = (model.clone()..invert()).transposed();
final Vector3 viewPosition = Vector3.copy(scene.camera.rotation);
final Material material = o.mesh[mesh].material;
// final Matrix4 normalTransform = (model.clone()..invert()).transposed();
// final Vector3 viewPosition = Vector3.copy(scene.camera.rotation);
// final Material material = o.mesh[mesh].material;
final List<Color> colors = o.mesh[mesh].colors;

//texture information
Expand Down Expand Up @@ -317,7 +317,7 @@ class ModelRender extends LevelEditor{
// });

for (int i = 0; i < indexCount; i++) {
if(renderPolys[i] != null){
//if(renderPolys[i] != null){
final int index0 = i * 3;
final int index1 = index0 + 1;
final int index2 = index0 + 2;
Expand All @@ -326,7 +326,7 @@ class ModelRender extends LevelEditor{
indices[index0] = triangle.vertexes[0];
indices[index1] = triangle.vertexes[1];
indices[index2] = triangle.vertexes[2];
}
//}

if(i < scene.objectTappedOn.length){
int sel = scene.objectTappedOn[i].objectLocation;
Expand Down Expand Up @@ -420,7 +420,7 @@ class ModelRender extends LevelEditor{
final Uint16List indices = Uint16List(indexCount * 3);

for (int i = 0; i < indexCount; i++) {
if(renderPolys[i] != null){
//if(renderPolys[i] != null){
final int index0 = i * 3;
final int index1 = index0 + 1;
final int index2 = index0 + 2;
Expand All @@ -429,7 +429,7 @@ class ModelRender extends LevelEditor{
indices[index0] = triangle.vertexes[0];
indices[index1] = triangle.vertexes[1];
indices[index2] = triangle.vertexes[2];
}
//}
}
_drwaVert(
canvas,
Expand All @@ -453,7 +453,7 @@ class ModelRender extends LevelEditor{
final Uint16List indices = Uint16List(indexCount * 3);

for (int i = 0; i < indexCount; i++) {
if(renderPolys[i] != null){
//if(renderPolys[i] != null){
final int index0 = i * 3;
final int index1 = index0 + 1;
final int index2 = index0 + 2;
Expand All @@ -462,7 +462,7 @@ class ModelRender extends LevelEditor{
indices[index0] = triangle.vertexes[0];
indices[index1] = triangle.vertexes[1];
indices[index2] = triangle.vertexes[2];
}
//}
}
_drwaVert(
canvas,
Expand Down
8 changes: 4 additions & 4 deletions lib/levelEditor/scene.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import 'level_editor.dart';
import '../editors/editors.dart';
import 'package:http/http.dart' as http;
import 'package:path/path.dart' as path;
import 'dart:math' as Math;
import 'dart:math' as math;

enum BrushStyles{stamp,fill,erase,move}

Expand Down Expand Up @@ -70,8 +70,8 @@ class LevelScene {
double y = point.dy - center.dy;

//APPLY ROTATION
double newX = x * Math.cos(angle) - y * Math.sin(angle);
double newY = x * Math.sin(angle) + y * Math.cos(angle);
double newX = x * math.cos(angle) - y * math.sin(angle);
double newY = x * math.sin(angle) + y * math.cos(angle);

//TRANSLATE BACK
return Offset(newX + center.dx, newY + center.dy);
Expand Down Expand Up @@ -464,7 +464,7 @@ class LevelScene {
int y = selectedTileLocation < width?0:(selectedTileLocation/width).floor();
int x = selectedTileLocation < width?selectedTileLocation:selectedTileLocation-width*y;
flood.floodFill(x, y).then((value){
levelInfo[selectedLevel].tileLayer[levelInfo[selectedLevel].selectedTileLayer].tiles = flood.allTiles as List<TileRects>;
levelInfo[selectedLevel].tileLayer[levelInfo[selectedLevel].selectedTileLayer].tiles = flood.allTiles;
});
}

Expand Down
4 changes: 2 additions & 2 deletions lib/levelEditor/text_edit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ class OverlayClass extends StatefulWidget {
final void Function(String)? onEditingComplete;

@override
_OverlayClassState createState() => _OverlayClassState();
OverlayClassState createState() => OverlayClassState();
}
class _OverlayClassState extends State<OverlayClass> {
class OverlayClassState extends State<OverlayClass> {
TextEditingController controller = TextEditingController();

@override
Expand Down
4 changes: 2 additions & 2 deletions lib/levelEditor/widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ class LevelEditor extends StatefulWidget {
final void Function({required LevelEditorCallbacks call, Offset? details})? callback;

@override
_LevelEditorState createState() => _LevelEditorState();
LevelEditorState createState() => LevelEditorState();
}

class _LevelEditorState extends State<LevelEditor> {
class LevelEditorState extends State<LevelEditor> {
late LevelScene scene;
Offset _lastFocalPoint = const Offset(0,0);
double? _lastZoom;
Expand Down
9 changes: 5 additions & 4 deletions lib/navigation/right_click.dart
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,14 @@ class RightClick{
}

class OverlayClass extends StatefulWidget {
OverlayClass({
const OverlayClass({
Key? key,
required this.style,
required this.width,
required this.theme,
required this.function,
required this.show,
});
}):super(key: key);

final ThemeData theme;
final TextStyle style;
Expand All @@ -136,9 +137,9 @@ class OverlayClass extends StatefulWidget {
final List<RightClickOptions> show;

@override
_OverlayClassState createState() => _OverlayClassState();
OverlayClassState createState() => OverlayClassState();
}
class _OverlayClassState extends State<OverlayClass> {
class OverlayClassState extends State<OverlayClass> {
RightClickOptions? hoverdOn;

@override
Expand Down
45 changes: 45 additions & 0 deletions lib/utils/logger.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import 'package:logger/logger.dart';

NRFLogger? logger;

/// Flutter Launcher Icons Logger
class NRFLogger {
late Logger _logger;

/// Returns true if this is a verbose logger
final bool isVerbose;

/// Gives access to internal logger
Logger get rawLogger => _logger;

/// Creates a instance of [FLILogger].
/// In case [isVerbose] is `true`,
/// it logs all the [verbose] logs to console
NRFLogger(this.isVerbose) {
_logger = Logger(
printer: PrettyPrinter(
methodCount: 2, // Number of method calls to be displayed
errorMethodCount: 8, // Number of method calls if stacktrace is provided
lineLength: 120, // Width of the output
colors: true, // Colorful log messages
printEmojis: true, // Print an emoji for each log message
printTime: true // Should each log print contain a timestamp
),
level: Level.all
);
}

/// Logs error messages
void error(Object? message) => _logger.e('Error Log', error: '⚠️ $message');

/// Prints to console if [isVerbose] is true
void verbose(Object? message){
if(isVerbose){
_logger.t(message.toString());
}
}
/// Prints to console if [isVerbose] is true
void warning(Object? message) => _logger.w(message.toString());
/// Prints to console
void info(Object? message) => _logger.i(message.toString());
}
Loading

0 comments on commit e0481f3

Please sign in to comment.