Index: src/newgrf_gui.cpp =================================================================== --- src/newgrf_gui.cpp (revision 12930) +++ src/newgrf_gui.cpp (working copy) @@ -15,6 +15,7 @@ #include "core/alloc_func.hpp" #include "string_func.h" #include "gfx_func.h" +#include "viewport_func.h" #include "table/strings.h" #include "table/sprites.h" @@ -479,6 +480,10 @@ WP(w, newgrf_d).sel = c; SetWindowDirty(w); + + /* Activate drag and drop */ + SetObjectToPlaceWnd(SPR_CURSOR_MOUSE, PAL_NONE, VHM_DRAG, w); + break; } @@ -507,6 +512,39 @@ } } break; + + case WE_DRAGDROP: { + GRFConfig **pc, *c, *source, *target; + + if ((source = WP(w, newgrf_d).sel) == NULL) break; + + uint i = (e->we.dragdrop.pt.y - w->widget[SNGRFS_FILE_LIST].top) / 13 + w->vscroll2.pos; + for (c = *WP(w, newgrf_d).list; c != NULL && i > 0; c = c->next, i--); + target = c; + + if (target == source) break; + + for (pc = WP(w, newgrf_d).list; (c = *pc) != NULL; pc = &c->next) { + if (c == source) + *pc = c->next; + else if (c->next == source) { + c->next = c->next->next; + } + + } + + for (pc = WP(w, newgrf_d).list; (c = *pc) != NULL; pc = &c->next) { + if (c == target) { + *pc = source; + source->next = target; + } + else if (c->next == target) { + c->next = source; + source->next = target; + } + } + SetWindowDirty(w); + } break; case WE_ON_EDIT_TEXT: if (e->we.edittext.str != NULL) {