|
104 | 104 | async function fetchTypeToEdit(idx: number) {
|
105 | 105 | try {
|
106 | 106 | const type = await invoke("get_type_full_info", { index: idx });
|
107 |
| - console.log("Loaded type for editing:", type); |
108 |
| - |
109 | 107 | parseTypeForEditing(type);
|
110 | 108 |
|
111 | 109 | } catch (e) {
|
|
842 | 840 | {/each}
|
843 | 841 | </div>
|
844 | 842 | {/if}
|
| 843 | + |
| 844 | + <!-- Object/Struct Protos --> |
| 845 | + {#if ["obj", "struct"].includes(typeKind)} |
| 846 | + <div class="space-y-4 mt-6"> |
| 847 | + <div class="flex items-center justify-between"> |
| 848 | + <h3 class="text-md font-medium text-surface-800 dark:text-surface-200">Prototypes</h3> |
| 849 | + <button |
| 850 | + class="btn btn-sm bg-primary-500 hover:bg-primary-600 text-white rounded-lg px-3 py-1.5 text-sm font-medium" |
| 851 | + onclick={addObjectProto} |
| 852 | + > |
| 853 | + Add Proto |
| 854 | + </button> |
| 855 | + </div> |
| 856 | + |
| 857 | + {#each objectProtos as proto, idx} |
| 858 | + <div class="flex items-center gap-3 p-3 bg-surface-50 dark:bg-surface-700 rounded-lg"> |
| 859 | + <span class="text-sm font-medium text-surface-600 dark:text-surface-400 min-w-[60px]"> |
| 860 | + Proto {idx}: |
| 861 | + </span> |
| 862 | + |
| 863 | + <!-- Proto Name --> |
| 864 | + <div class="flex-1 relative popover-container"> |
| 865 | + <button |
| 866 | + type="button" |
| 867 | + class="input w-full text-left flex items-center justify-between |
| 868 | + bg-white dark:bg-surface-700 border border-surface-300 dark:border-surface-600 |
| 869 | + rounded-lg px-3 py-2 text-sm hover:border-primary-400" |
| 870 | + onclick={() => openPopover(`protoName-${idx}`)} |
| 871 | + > |
| 872 | + <span class={proto.name ? 'text-surface-900 dark:text-surface-100' : 'text-surface-500 dark:text-surface-400'}> |
| 873 | + {proto.name ? availableStrings.find(s => s.idx === +proto.name)?.value ?? proto.name : 'Select name...'} |
| 874 | + </span> |
| 875 | + <svg class="w-4 h-4 text-surface-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 876 | + <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path> |
| 877 | + </svg> |
| 878 | + </button> |
| 879 | + |
| 880 | + {#if activePopover === `protoName-${idx}`} |
| 881 | + <div class="absolute top-full left-0 right-0 mt-1 bg-white dark:bg-surface-800 border border-surface-200 dark:border-surface-700 rounded-lg shadow-lg z-50"> |
| 882 | + <div class="p-3 border-b border-surface-200 dark:border-surface-700"> |
| 883 | + <input |
| 884 | + class="w-full px-3 py-2 text-sm border border-surface-300 dark:border-surface-600 rounded-md |
| 885 | + bg-white dark:bg-surface-700 text-surface-900 dark:text-surface-100" |
| 886 | + type="text" |
| 887 | + placeholder="Search strings..." |
| 888 | + bind:value={popoverSearchQueries[`protoName-${idx}`]} |
| 889 | + /> |
| 890 | + </div> |
| 891 | + <div class="max-h-48 overflow-y-auto"> |
| 892 | + {#each getFilteredStrings(popoverSearchQueries[`protoName-${idx}`] || '') as str} |
| 893 | + <button |
| 894 | + class="w-full px-3 py-2 text-left text-sm hover:bg-surface-100 dark:hover:bg-surface-700 |
| 895 | + text-surface-900 dark:text-surface-100 flex items-center justify-between" |
| 896 | + onclick={() => { |
| 897 | + objectProtos = objectProtos.map((p, i) => i === idx ? { ...p, name: String(str.idx) } : p); |
| 898 | + closePopover(); |
| 899 | + }} |
| 900 | + > |
| 901 | + <span class="font-mono">{str.value}</span> |
| 902 | + <span class="text-xs text-surface-500">@{str.idx}</span> |
| 903 | + </button> |
| 904 | + {/each} |
| 905 | + </div> |
| 906 | + </div> |
| 907 | + {/if} |
| 908 | + </div> |
| 909 | + |
| 910 | + <!-- Function Index --> |
| 911 | + <div class="flex-1 relative popover-container"> |
| 912 | + <button |
| 913 | + type="button" |
| 914 | + class="input w-full text-left flex items-center justify-between |
| 915 | + bg-white dark:bg-surface-700 border border-surface-300 dark:border-surface-600 |
| 916 | + rounded-lg px-3 py-2 text-sm hover:border-primary-400" |
| 917 | + onclick={() => openPopover(`protoFindex-${idx}`)} |
| 918 | + > |
| 919 | + <span class={proto.findex ? 'text-surface-900 dark:text-surface-100' : 'text-surface-500 dark:text-surface-400'}> |
| 920 | + {proto.findex ? availableFunctions.find(f => f.idx === +proto.findex)?.value ?? proto.findex : 'Select function...'} |
| 921 | + </span> |
| 922 | + <svg class="w-4 h-4 text-surface-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 923 | + <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path> |
| 924 | + </svg> |
| 925 | + </button> |
| 926 | + |
| 927 | + {#if activePopover === `protoFindex-${idx}`} |
| 928 | + <div class="absolute top-full left-0 right-0 mt-1 bg-white dark:bg-surface-800 border border-surface-200 dark:border-surface-700 rounded-lg shadow-lg z-50"> |
| 929 | + <div class="p-3 border-b border-surface-200 dark:border-surface-700"> |
| 930 | + <input |
| 931 | + class="w-full px-3 py-2 text-sm border border-surface-300 dark:border-surface-600 rounded-md |
| 932 | + bg-white dark:bg-surface-700 text-surface-900 dark:text-surface-100" |
| 933 | + type="text" |
| 934 | + placeholder="Search functions..." |
| 935 | + bind:value={popoverSearchQueries[`protoFindex-${idx}`]} |
| 936 | + /> |
| 937 | + </div> |
| 938 | + <div class="max-h-48 overflow-y-auto"> |
| 939 | + {#each getFilteredFunctions(popoverSearchQueries[`protoFindex-${idx}`] || '') as func} |
| 940 | + <button |
| 941 | + class="w-full px-3 py-2 text-left text-sm hover:bg-surface-100 dark:hover:bg-surface-700 |
| 942 | + text-surface-900 dark:text-surface-100 flex items-center justify-between" |
| 943 | + onclick={() => { |
| 944 | + objectProtos = objectProtos.map((p, i) => i === idx ? { ...p, findex: String(func.idx) } : p); |
| 945 | + closePopover(); |
| 946 | + }} |
| 947 | + > |
| 948 | + <span class="font-mono">{func.value}</span> |
| 949 | + <span class="text-xs text-surface-500">@{func.idx}</span> |
| 950 | + </button> |
| 951 | + {/each} |
| 952 | + </div> |
| 953 | + </div> |
| 954 | + {/if} |
| 955 | + </div> |
| 956 | + |
| 957 | + <!-- Proto Index --> |
| 958 | + <div class="w-32"> |
| 959 | + <input |
| 960 | + class="input w-full px-3 py-2 text-sm border border-surface-300 dark:border-surface-600 rounded-lg |
| 961 | + bg-white dark:bg-surface-700 text-surface-900 dark:text-surface-100" |
| 962 | + type="number" |
| 963 | + placeholder="PIndex" |
| 964 | + bind:value={proto.pindex} |
| 965 | + /> |
| 966 | + </div> |
| 967 | + |
| 968 | + <button |
| 969 | + class="btn btn-sm bg-error-500 hover:bg-error-600 text-white rounded-lg px-2 py-1.5" |
| 970 | + onclick={() => removeObjectProto(idx)} |
| 971 | + > |
| 972 | + Remove |
| 973 | + </button> |
| 974 | + </div> |
| 975 | + {/each} |
| 976 | + </div> |
| 977 | + {/if} |
845 | 978 | </div>
|
846 | 979 | {/if}
|
847 | 980 |
|
|
0 commit comments