Made the rtb only use 1 string and made the Nomai Branches have a start pos and use a beter cordent system
This commit is contained in:
@@ -34,7 +34,6 @@ unsigned char __Close__ = 0;
|
|||||||
|
|
||||||
void programClose(int sig) {
|
void programClose(int sig) {
|
||||||
term_threaded_input_stop();
|
term_threaded_input_stop();
|
||||||
term_enable_cursor();
|
|
||||||
__Close__ = 1;
|
__Close__ = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,41 +56,36 @@ void SetRichTextBox(richTextBox* rtb, char* text, int len,
|
|||||||
char* p = text;
|
char* p = text;
|
||||||
unsigned char found = 0;
|
unsigned char found = 0;
|
||||||
rtb->stringCount = 5;
|
rtb->stringCount = 5;
|
||||||
|
rtb->text = text;
|
||||||
int sizeOfString = 0;
|
int sizeOfString = 0;
|
||||||
for(int i = 0; i < len; i++) {
|
|
||||||
sizeOfString = i - textOffset;
|
|
||||||
|
|
||||||
if(p[i] == '\n') {
|
|
||||||
// This means that it will start splitting strings
|
|
||||||
found = 1;
|
|
||||||
|
|
||||||
//p[i] = '\0'; // Sets this to be the end of the string
|
|
||||||
|
|
||||||
//Add the address to the cstring
|
|
||||||
if(lineCount == 5) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
rtb->textBox[lineCount] = tart_cstring(p + textOffset,
|
|
||||||
sizeOfString, rtb->cell);
|
|
||||||
textOffset = i + 1; // Sets the start of the next string.
|
|
||||||
lineCount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tart_cstring_free(&rtb->textBox[lineCount]);
|
|
||||||
rtb->textBox[lineCount] = tart_cstring(p + textOffset,
|
|
||||||
strlen(p), rtb->cell);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawTextBox(struct tart_window* window, richTextBox* rtb, tart_byte id) {
|
void drawTextBox(struct tart_window* window, richTextBox* rtb, tart_byte id) {
|
||||||
struct tart_buffer* sb = tart_get_buffer(window, id);
|
struct tart_buffer* sb = tart_get_buffer(window, id);
|
||||||
// This makes sure that we dont go outside of memeery with the string count.
|
int lineNo = 0;
|
||||||
for (int lineNo = 0; lineNo < rtb->stringCount; lineNo++) {
|
int lineStart = 0;
|
||||||
tart_draw_cstring_position(sb,
|
for(int i = 0; i < strlen(rtb->text); i++) {
|
||||||
rtb->textBox[lineNo],
|
if(rtb->text[i] == '\n') {
|
||||||
(struct tart_vec2){rtb->pos.x,rtb->pos.y + lineNo});
|
rtb->textBox[0] = tart_cstring(
|
||||||
|
&rtb->text[0]+lineStart,
|
||||||
|
i - lineStart,
|
||||||
|
NULL_CELL);
|
||||||
|
tart_draw_cstring_position(sb,
|
||||||
|
rtb->textBox[0],
|
||||||
|
(struct tart_vec2){rtb->pos.x, rtb->pos.y+lineNo});
|
||||||
|
tart_cstring_free(&rtb->textBox[0]);
|
||||||
|
lineNo++;
|
||||||
|
lineStart = i + 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
rtb->textBox[0] = tart_cstring(
|
||||||
|
&rtb->text[0]+lineStart,
|
||||||
|
strlen(rtb->text) - lineStart,
|
||||||
|
NULL_CELL);
|
||||||
|
tart_draw_cstring_position(sb,
|
||||||
|
rtb->textBox[0],
|
||||||
|
(struct tart_vec2){rtb->pos.x, rtb->pos.y+lineNo});
|
||||||
|
tart_cstring_free(&rtb->textBox[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//############ Init Commands ############
|
//############ Init Commands ############
|
||||||
@@ -124,6 +118,10 @@ int main (int argc, char *argv[]) {
|
|||||||
char commandInput[255] = "";
|
char commandInput[255] = "";
|
||||||
unsigned char keyPressed = 0;
|
unsigned char keyPressed = 0;
|
||||||
|
|
||||||
|
branch b = {
|
||||||
|
.startPos = (struct tart_vec2){term_current_size().x/2,term_current_size().y- 10},
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// Window Createion
|
// Window Createion
|
||||||
struct tart_window window = tart_create_window();
|
struct tart_window window = tart_create_window();
|
||||||
@@ -260,7 +258,8 @@ int main (int argc, char *argv[]) {
|
|||||||
drawTextBox(&window, &inputRtb, 0);
|
drawTextBox(&window, &inputRtb, 0);
|
||||||
|
|
||||||
|
|
||||||
DrawBranch(NULL, &window, 0);
|
|
||||||
|
DrawBranch(&b, &window, 0);
|
||||||
|
|
||||||
tart_draw_window(&window, 0);
|
tart_draw_window(&window, 0);
|
||||||
if(mode == COMMAND_MODE) {
|
if(mode == COMMAND_MODE) {
|
||||||
@@ -285,5 +284,6 @@ int main (int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tart_destroy_window(&window);
|
tart_destroy_window(&window);
|
||||||
|
term_enable_cursor();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,13 +50,21 @@ void DrawBranch(branch* branch, struct tart_window* w, tart_byte b) {
|
|||||||
cell.display = '*';
|
cell.display = '*';
|
||||||
struct nomiSpirel spirel;
|
struct nomiSpirel spirel;
|
||||||
int SizeOfFile = 600;
|
int SizeOfFile = 600;
|
||||||
char cellChart[] = {'%','*','\\','/','l','&','b','+','=','^',':'};
|
char cellChart[] = {'%','*','\\','/','l','&','7','+','=','^',':'};
|
||||||
unsigned int iderations = 0;
|
unsigned int iderations = 0;
|
||||||
|
|
||||||
struct tart_vec2 pos0 = {15+30, 0/2};
|
struct tart_vec2 pos0 = {
|
||||||
struct tart_vec2 c0 = { 0+30,30/2}; // controle point 0
|
(( 3) * -1)+branch->startPos.x,
|
||||||
struct tart_vec2 c1 = {30+30,19/2}; // controle point 1
|
(( 0/2) * -1)+branch->startPos.y};
|
||||||
struct tart_vec2 pos1 = {17+30,11/2};
|
struct tart_vec2 c0 = {
|
||||||
|
(( 25) * -1)+branch->startPos.x,
|
||||||
|
((35/2) * -1)+branch->startPos.y}; // controle point 0
|
||||||
|
struct tart_vec2 c1 = {
|
||||||
|
(( -10) * -1)+branch->startPos.x,
|
||||||
|
((35/2) * -1)+branch->startPos.y}; // controle point 1
|
||||||
|
struct tart_vec2 pos1 = {
|
||||||
|
(( 3) * -1)+branch->startPos.x,
|
||||||
|
((10/2) * -1)+branch->startPos.y};
|
||||||
|
|
||||||
struct tart_vec2 dpos = {0,0};
|
struct tart_vec2 dpos = {0,0};
|
||||||
float count = 0;
|
float count = 0;
|
||||||
@@ -74,10 +82,10 @@ void DrawBranch(branch* branch, struct tart_window* w, tart_byte b) {
|
|||||||
cell.display = cellChart[rand_r(&iderations)%11];
|
cell.display = cellChart[rand_r(&iderations)%11];
|
||||||
|
|
||||||
dpos = (struct tart_vec2){
|
dpos = (struct tart_vec2){
|
||||||
(1-count)*((1-count)*((1-count)*pos0.x + count * c0.x) + count *
|
(1-count)*((1-count)*((1-count)*pos0.x + count * c0.x) +
|
||||||
((1-count)*c0.x + count*c1.x)) +
|
count * ((1-count)*c0.x + count*c1.x)) +
|
||||||
count *((1-count)*((1-count)*c0.x + count * c1.x) +
|
count * ((1-count)*((1-count)*c0.x + count * c1.x) +
|
||||||
count * ((1-count)*c1.x + pos1.x)),
|
count * ((1-count)*c1.x + pos1.x)),
|
||||||
(1-count)*((1-count)*((1-count)*pos0.y + count * c0.y) + count *
|
(1-count)*((1-count)*((1-count)*pos0.y + count * c0.y) + count *
|
||||||
((1-count)*c0.y + count*c1.y)) +
|
((1-count)*c0.y + count*c1.y)) +
|
||||||
count *((1-count)*((1-count)*c0.y + count * c1.y) +
|
count *((1-count)*((1-count)*c0.y + count * c1.y) +
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ typedef struct {
|
|||||||
branchId children[MAX_CHILDREN]; // holds the branchIds of its children
|
branchId children[MAX_CHILDREN]; // holds the branchIds of its children
|
||||||
void* parent; // points the the branches parent
|
void* parent; // points the the branches parent
|
||||||
char type; // holds the type as in if this struct is a branch or a trunk
|
char type; // holds the type as in if this struct is a branch or a trunk
|
||||||
|
struct tart_vec2 startPos; // the starting position of the branch
|
||||||
branchId id; // This holds the branch id.
|
branchId id; // This holds the branch id.
|
||||||
} branch;
|
} branch;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user