@@ -516,16 +516,24 @@ document.addEventListener("DOMContentLoaded", () => {
516516 id : "action" ,
517517 label : "Action" ,
518518 value : "Duplicate" ,
519- options : [ "Duplicate" , "Rename" ] ,
519+ options : [ "Duplicate" , "Rename" , "Copy controls" ] ,
520520 } ,
521521 ] ) ;
522522
523523 if ( ! choice ) return ;
524524
525- if ( choice . action === "Duplicate" ) {
526- openCloneProfileModal ( ) ;
527- } else if ( choice . action === "Rename" ) {
528- await handleProfileRename ( ) ;
525+ switch ( choice ?. action ) {
526+ case "Duplicate" :
527+ openCloneProfileModal ( ) ;
528+ break ;
529+
530+ case "Rename" :
531+ await handleProfileRename ( ) ;
532+ break ;
533+
534+ case "Copy controls" :
535+ await handleCopyControls ( ) ;
536+ break ;
529537 }
530538 } ) ;
531539
@@ -549,6 +557,69 @@ document.addEventListener("DOMContentLoaded", () => {
549557 }
550558 }
551559
560+ async function handleCopyControls ( ) {
561+ if ( ! window . selectedProfilePath ) {
562+ showToast ( "No source profile selected!" , "warning" ) ;
563+ return ;
564+ }
565+
566+ try {
567+ const profiles = await invoke ( "find_ets2_profiles" ) ;
568+
569+ const sourcePath = window . selectedProfilePath ;
570+ const targets = profiles . filter (
571+ ( p ) => p . success && p . path !== sourcePath
572+ ) ;
573+
574+ if ( targets . length === 0 ) {
575+ showToast ( "No other profiles available." , "warning" ) ;
576+ return ;
577+ }
578+
579+ const options = targets . map (
580+ ( p ) => `${ p . name } [${ p . path } ]`
581+ ) ;
582+
583+ const res = await openModalMulti ( "Copy Controls" , [
584+ {
585+ type : "dropdown" ,
586+ id : "target" ,
587+ label : "Target Profile" ,
588+ value : options [ 0 ] ,
589+ options,
590+ } ,
591+ ] ) ;
592+
593+ if ( ! res || ! res . target ) return ;
594+
595+ const selectedProfile = targets . find (
596+ ( p ) => `${ p . name } [${ p . path } ]` === res . target
597+ ) ;
598+
599+ if ( ! selectedProfile ) {
600+ showToast ( "Invalid profile selected." , "error" ) ;
601+ return ;
602+ }
603+
604+ showToast ( "Copying controls…" , "info" ) ;
605+
606+ const msg = await invoke ( "copy_profile_controls" , {
607+ sourceProfilePath : sourcePath ,
608+ targetProfilePath : selectedProfile . path ,
609+ } ) ;
610+
611+ showToast ( msg , "success" ) ;
612+
613+ } catch ( err ) {
614+ console . error ( "Copy controls failed:" , err ) ;
615+ showToast (
616+ typeof err === "string" ? err : "Failed to copy controls." ,
617+ "error"
618+ ) ;
619+ }
620+ }
621+
622+
552623 // -----------------------------
553624 // MOVE MODS LOGIC
554625 // -----------------------------
0 commit comments