Skip to content

Commit

Permalink
feat: Combinadas las queues de drag and drop y comandos.
Browse files Browse the repository at this point in the history
no testeado en windows mejor usá winamp lmao
  • Loading branch information
fedpo2 committed Sep 16, 2023
1 parent 5112ef6 commit 28c5e95
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
17 changes: 12 additions & 5 deletions src/Program.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#define HELP_EXIT() show_help_message(); return 0

void load_paths(struct linked_node** p, char** str, int cant){
for (int i = cant-1; i>0; i--) {
for (int i = cant; i>0; i--) {
top_push(p,str[i]);
}
}
Expand Down Expand Up @@ -44,7 +44,7 @@ int main (int argc, char *argv[]) {

struct linked_node* path = NULL;

load_paths(&path, argv, argc);
load_paths(&path, argv, argc-1);
int ind = argc;

//NOTE: this is for debugging
Expand Down Expand Up @@ -104,7 +104,7 @@ int main (int argc, char *argv[]) {
}

if (IsKeyReleased(KEY_RIGHT)) {
if(selector < ind-1){
if(selector < ind-2){
++selector;
lastTime = 0.0f;
music = LoadMusicStream(get_value(path, selector));
Expand All @@ -116,11 +116,18 @@ int main (int argc, char *argv[]) {
FilePathList droppedFiles = LoadDroppedFiles();

end_push(&path, droppedFiles.paths[0]);
selector = ++ind;
ind++;

selector = 0;
music = LoadMusicStream(get_value(path, selector));
PlayMusicStream(music);

UnloadDroppedFiles(droppedFiles);

//NOTE: this is for debugging
printf("\n\n");
print_list(path);
//

}

BeginDrawing();
Expand Down
19 changes: 14 additions & 5 deletions src/linkedList.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ void print_list(struct linked_node *p){
char* get_value(struct linked_node *p ,int index){
if( index == 0 ) return p->value;
while(index != 0){
if(p->next != NULL && p != NULL){
if(p->next->value != NULL && p != NULL){
p = p->next;
--index;
}else{
Expand All @@ -24,21 +24,27 @@ char* get_value(struct linked_node *p ,int index){
void top_push(struct linked_node** head, char* str){
struct linked_node* new_head;
new_head = (struct linked_node*)malloc(sizeof(struct linked_node));
new_head->value = str;
char* str2 = malloc(strlen(str)+1);
strcpy(str2, str);
new_head->value = str2;
new_head->next = *head;
*head = new_head;
}

void end_push(struct linked_node** head, char* str){

char* str2 = malloc(strlen(str)+1);
strcpy(str2, str);

if (*head == NULL){
struct linked_node* new_head = malloc(sizeof(struct linked_node));
new_head->value = str;
struct linked_node* new_head = (struct linked_node*)malloc(sizeof(struct linked_node));
new_head->value = str2;
*head = new_head;
return;
}

struct linked_node* new_head = malloc(sizeof(struct linked_node));
new_head->value = str;
new_head->value = str2;

struct linked_node* p = *head;
while (p->next != NULL){
Expand All @@ -55,6 +61,8 @@ char* top_pop(struct linked_node** head){

struct linked_node* nnode = (*head)->next;
devolucion = (*head)->value;

free((*head)->value);
free(*head);
*head = nnode;
return devolucion;
Expand All @@ -71,6 +79,7 @@ char* end_pop(struct linked_node** head){

if(lnode != NULL){
devolucion = lnode->value;
free(lnode->value);
free(lnode);
}
return devolucion;
Expand Down
1 change: 1 addition & 0 deletions src/linkedList.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

struct linked_node {
char* value;
Expand Down

0 comments on commit 28c5e95

Please sign in to comment.